Python Forum
Problem to sent message with pyserial and ser.write
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem to sent message with pyserial and ser.write
#1
Hello Everybody,

I need your help to solve a problem.

I need to send command line in MESSAGE BOARD - MML16R Velleman connect by USB/RS232 in Raspberry.
[Image: mml16r.jpg]

I use Pyserial and this command :

ser.write(message.encode('ascii'))
This is the message :
<ID00><BE>05<E><ID00><L1><PA><FE><MA><WC><FE>Bonjour35<E><ID00><BF>06<E> (it mean Hello)
<ID00><BE>05<E><ID00><L1><PA><FE><MA><WC><FE>Bonjour tout le monde6B<E><ID00><BF>06<E> (it mean Hello everybody)

The first message is sent.
But, the second don't work.

Do you have an idea ?

Thank you very much
Reply
#2
Please provide a bit more information, such as:
  • Where to get specs and programming information for MESSAGE BOARD - MML16R
  • You full, runable code.
Reply
#3
Thank you for your anwer Larz60+

This is my code :
import time
import serial

ser=serial.Serial(
port='/dev/ttyUSB0',
baudrate = 9600,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
)


counter ='<ID00><BE>05<E><ID00><L1><PA><FE><MA><WC><FE>Bonjour35<E><ID00><BF>06<E>'
	ser.write(counter.encode('ascii'))
	
time.sleep(2)
About code, Velleman do not communicate about programming.
That's why I'm using a sniffer for RS232 communication, and I get this code after sending the instructions from the Newsign software that Velleman provides for Windows 10
<ID00><BE>05<E><ID00><L1><PA><FE><MA><WC><FE>Bonjour35<E><ID00><BF>06<E>

Do you need more information ? Smile
Reply
#4
Where to get specs and programming information for MESSAGE BOARD - MML16R
Reply
#5
In this page : https://www.velleman.eu/products/view/?id=372614

and documentation here : https://www.velleman.eu/downloads/6/mml1...lfresd.pdf

Page 40, I have information :

Bits per second : 9600
Data bits : 8
Parity : None
Stop bits : 1
Flow control : Xon/Xoff
Reply
#6
FYI: Found links here: https://www.velleman.eu/support/downloads/?code=MML16R
User Manual: https://www.velleman.eu/downloads/6/mml1...lfresd.pdf
Addendum: https://www.velleman.eu/downloads/6/mess...dum401.pdf
Reply
#7
Yes, I edit my topic with this pdf when you posted your answer :)

I obtain this information when I use Newsign software and send the command.

000231: Create Request (DOWN), 2019-04-14 15:09:38,5743158 +33,0246753 (1. Device: Silicon Labs CP210x USB to UART Bridge (COM10))
Process 0x5278 (NewSign V2.2_Has_ 255COM.exe) attempted to open the device
000232: Create Request (UP), 2019-04-14 15:09:38,5767185 +0,0024027 (1. Device: Silicon Labs CP210x USB to UART Bridge (COM10))
Process 0x5278 (NewSign V2.2_Has_ 255COM.exe) create request status: 0x00000000
000233: I/O Request (DOWN), 2019-04-14 15:09:38,5767330 +0,0000145 (1. Device: Silicon Labs CP210x USB to UART Bridge (COM10))
IOCTL_SERIAL_SET_QUEUE_SIZE: Set queue size
  InSize=1024
  OutSize=1024
000236: I/O Request (UP), 2019-04-14 15:09:38,5767529 +0,0000024 (1. Device: Silicon Labs CP210x USB to UART Bridge (COM10))
IOCTL_SERIAL_GET_TIMEOUTS: Retrieve timeouts
  ReadIntervalTimeout=10
  ReadTotalTimeoutMultiplier=0
  ReadTotalTimeoutConstant=1100
  WriteTotalTimeoutMultiplier=10
  WriteTotalTimeoutConstant=300
000237: I/O Request (DOWN), 2019-04-14 15:09:38,5767614 +0,0000085 (1. Device: Silicon Labs CP210x USB to UART Bridge (COM10))
IOCTL_SERIAL_SET_TIMEOUTS: Set timeouts
  ReadIntervalTimeout=10
  ReadTotalTimeoutMultiplier=0
  ReadTotalTimeoutConstant=1100
  WriteTotalTimeoutMultiplier=10
  WriteTotalTimeoutConstant=300
000240: I/O Request (UP), 2019-04-14 15:09:38,5767735 +0,0000018 (1. Device: Silicon Labs CP210x USB to UART Bridge (COM10))
IOCTL_SERIAL_GET_BAUD_RATE: Retrieve Baud Rate
  Baud Rate=9600

000242: I/O Request (UP), 2019-04-14 15:09:38,5767801 +0,0000018 (1. Device: Silicon Labs CP210x USB to UART Bridge (COM10))
IOCTL_SERIAL_GET_LINE_CONTROL: Retrieve line control
  WordLength=8
  StopBits=1 stop bit
  Parity=No parity

000244: I/O Request (UP), 2019-04-14 15:09:38,5767861 +0,0000015 (1. Device: Silicon Labs CP210x USB to UART Bridge (COM10))
IOCTL_SERIAL_GET_CHARS: Retrieve special characters
  EofChar=0x0
  ErrorChar=0x0
  BreakChar=0x0
  EventChar=0x0
  XonChar=0x11
  XoffChar=0x13
000246: I/O Request (UP), 2019-04-14 15:09:38,5767913 +0,0000012 (1. Device: Silicon Labs CP210x USB to UART Bridge (COM10))
IOCTL_SERIAL_GET_HANDFLOW: Retrieve handshake information
  ControlHandShake=0
  FlowReplace=3
  XonLimit=32768
  XoffLimit=8192

000248: I/O Request (UP), 2019-04-14 15:09:38,5768000 +0,0000015 (1. Device: Silicon Labs CP210x USB to UART Bridge (COM10))
IOCTL_SERIAL_GET_BAUD_RATE: Retrieve Baud Rate
  Baud Rate=9600

000250: I/O Request (UP), 2019-04-14 15:09:38,5768055 +0,0000015 (1. Device: Silicon Labs CP210x USB to UART Bridge (COM10))
IOCTL_SERIAL_GET_LINE_CONTROL: Retrieve line control
  WordLength=8
  StopBits=1 stop bit
  Parity=No parity

000252: I/O Request (UP), 2019-04-14 15:09:38,5768106 +0,0000015 (1. Device: Silicon Labs CP210x USB to UART Bridge (COM10))
IOCTL_SERIAL_GET_CHARS: Retrieve special characters
  EofChar=0x0
  ErrorChar=0x0
  BreakChar=0x0
  EventChar=0x0
  XonChar=0x11
  XoffChar=0x13
000254: I/O Request (UP), 2019-04-14 15:09:38,5768160 +0,0000015 (1. Device: Silicon Labs CP210x USB to UART Bridge (COM10))
IOCTL_SERIAL_GET_HANDFLOW: Retrieve handshake information
  ControlHandShake=0
  FlowReplace=3
  XonLimit=32768
  XoffLimit=8192

000255: I/O Request (DOWN), 2019-04-14 15:09:38,5768224 +0,0000064 (1. Device: Silicon Labs CP210x USB to UART Bridge (COM10))
IOCTL_SERIAL_SET_BAUD_RATE: Set baud rate
  Baud Rate=9600

000257: I/O Request (DOWN), 2019-04-14 15:09:38,5773280 +0,0000921 (1. Device: Silicon Labs CP210x USB to UART Bridge (COM10))
IOCTL_SERIAL_CLR_RTS: Clear RTS

000259: I/O Request (DOWN), 2019-04-14 15:09:38,5775888 +0,0000947 (1. Device: Silicon Labs CP210x USB to UART Bridge (COM10))
IOCTL_SERIAL_CLR_DTR: Clear DTR

000261: I/O Request (DOWN), 2019-04-14 15:09:38,5784910 +0,0001170 (1. Device: Silicon Labs CP210x USB to UART Bridge (COM10))
IOCTL_SERIAL_SET_LINE_CONTROL: Set line control
  WordLength=8
  StopBits=1 stop bit
  Parity=No parity

000263: I/O Request (DOWN), 2019-04-14 15:09:38,5789891 +0,0000896 (1. Device: Silicon Labs CP210x USB to UART Bridge (COM10))
IOCTL_SERIAL_SET_CHARS: Set special characters
  EofChar=0x0
  ErrorChar=0x0
  BreakChar=0x0
  EventChar=0x0
  XonChar=0x11
  XoffChar=0x13
000265: I/O Request (DOWN), 2019-04-14 15:09:38,5792478 +0,0000890 (1. Device: Silicon Labs CP210x USB to UART Bridge (COM10))
IOCTL_SERIAL_SET_HANDFLOW: Set handshake information
  ControlHandShake=0
  FlowReplace=3
  XonLimit=32768
  XoffLimit=8192

000267: Write Request (DOWN), 2019-04-14 15:09:38,5795210 +0,0000440 (1. Device: Silicon Labs CP210x USB to UART Bridge (COM10))
Buffer size: 0x60 bytes

000459: Close Request (DOWN), 2019-04-14 15:09:39,1055007 +0,0000407 (1. Device: Silicon Labs CP210x USB to UART Bridge (COM10))
Buffer size: 0x0 bytes
Reply
#8
I installed cutecom on my raspberry, and it sends the commands to the hardware correctly.

I compared the differences between cutecom and the python script.
I have to add the following parameters to the python script:
--eol CRLF
- char delay = 5 ms.

Can you tell me if it is possible to include its 2 parameters in my python file, and how?

Thank you for your reply.
Reply
#9
'\n' is CRLF
delay 5ms
from time import sleep
sleep(0.005)
Reply
#10
Thank you Larz60+ !

I have little small problem :
ser.write(message.encode('ascii')+'\n')
It's not work, is my syntax is good ?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  write to csv file problem jacksfrustration 11 1,502 Nov-09-2023, 01:56 PM
Last Post: deanhystad
  little problem with read out and write into a file hello_its_me 11 8,525 Sep-04-2017, 11:54 AM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020