Python Forum

Full Version: Problem to sent message with pyserial and ser.write
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
message = f'{message}\n'
ser.write(message.encode('ascii')
f-string require python 3.6 or newer
alternative:
message = '{}\n'.format(message)
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
Are you asking how to add CRLF to these?
if so use same method as with message
example:
ReadInterval = '{}\n'.format(2147483647)
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?
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.
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.
Thank you for your help Larz60+ :)
YES, I think you are rigth !
Do you have any idea how I can improve my code?
Don't have time to look at it now, perhaps later
Thank you Larz60+, I will try to continue my research :)
Pages: 1 2