Python Forum
Problem to sent message with pyserial and ser.write - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Problem to sent message with pyserial and ser.write (/thread-17511.html)

Pages: 1 2


Problem to sent message with pyserial and ser.write - DJ_Depannage - Apr-14-2019

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


RE: Problem to sent message with pyserial and ser.write - Larz60+ - Apr-14-2019

Please provide a bit more information, such as:
  • Where to get specs and programming information for MESSAGE BOARD - MML16R
  • You full, runable code.



RE: Problem to sent message with pyserial and ser.write - DJ_Depannage - Apr-14-2019

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


RE: Problem to sent message with pyserial and ser.write - Larz60+ - Apr-14-2019

Where to get specs and programming information for MESSAGE BOARD - MML16R


RE: Problem to sent message with pyserial and ser.write - DJ_Depannage - Apr-14-2019

In this page : https://www.velleman.eu/products/view/?id=372614

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

Page 40, I have information :

Bits per second : 9600
Data bits : 8
Parity : None
Stop bits : 1
Flow control : Xon/Xoff


RE: Problem to sent message with pyserial and ser.write - Larz60+ - Apr-14-2019

FYI: Found links here: https://www.velleman.eu/support/downloads/?code=MML16R
User Manual: https://www.velleman.eu/downloads/6/mml16cnmml16rgbnlfresd.pdf
Addendum: https://www.velleman.eu/downloads/6/messageboardsaddendum401.pdf


RE: Problem to sent message with pyserial and ser.write - DJ_Depannage - Apr-14-2019

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



RE: Problem to sent message with pyserial and ser.write - DJ_Depannage - Apr-14-2019

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.


RE: Problem to sent message with pyserial and ser.write - Larz60+ - Apr-14-2019

'\n' is CRLF
delay 5ms
from time import sleep
sleep(0.005)



RE: Problem to sent message with pyserial and ser.write - DJ_Depannage - Apr-14-2019

Thank you Larz60+ !

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