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


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

message = f'{message}\n'
ser.write(message.encode('ascii')
f-string require python 3.6 or newer
alternative:
message = '{}\n'.format(message)



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

Thank you Larz60+ :)

Is it possible to have the equivalent of the following line in python please ?

ReadInterval=2147483647, ReadTotalTimeoutMultiplier=0, ReadTotalTimeoutConstant=1100, WriteTotalTimeoutMultiplier=0, WriteTotalTimeoutConstant=0



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

Are you asking how to add CRLF to these?
if so use same method as with message
example:
ReadInterval = '{}\n'.format(2147483647)


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

Sorry, english is not my native language.
I need to improve the communication of the script to the serial port.
The display is very capricious on receiving the data.
The display captures only 1 word. If I send 10 words for example, it blocks and displays nothing.
I should be able to regulate the speed of sending the order or something like that.

The sniper give me this value when I send the orders :
  • XonLimit = 32768
    XoffLimit = 8192
    ReadInterval = 0, sometimes 2147483647
    ReadTotalTimeoutMultiplier = 0
    ReadTotalTimeoutConstant = 1100
    WriteTotalTimeoutMultiplier = 0
    WriteTotalTimeoutConstant = 0

Is it possible to import its values into pyserial, and if so how?


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

I read in the pyserial documentation that XonXoff can have the value: True or False.
It is not possible to have?
Xon = 32768
Xoff = 8192

With cutecom, everything works perfectly.
It's why I think I have problem with RS232 communication in my python script.


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

Xon, Xoff is (usually, and hopefully with this package as well ) serial flow control and stands for pause transmission and resume transmission so would be a Boolean value.


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

Thank you for your help Larz60+ :)
YES, I think you are rigth !
Do you have any idea how I can improve my code?


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

Don't have time to look at it now, perhaps later


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

Thank you Larz60+, I will try to continue my research :)