PySerial changing device flags
I can communicate with a device over UART with the following command in the linux shell:
echo "abcd" > /dev/ttymxc6
I am using this UART for RS485 communication. The communication works well on the linux shell but when I use pymodbus, it creates a Serial (https://github.com/riptideio/pymodbus/blob/efb90fb05882d606933a97435dd37ae87ead5449/pymodbus/client/sync.py#L593) and this add the "opost" flag to ttymxc6 for unknown reasons.
Without using pymodbus (and so pyserial):
root@user:~# stty -F /dev/ttymxc6
speed 9600 baud; line = 0;
-brkint -imaxbel
After using pymodbus:
root@user:~# stty -F /dev/ttymxc6
speed 9600 baud; line = 0;
min = 0; time = 0;
-brkint -icrnl -imaxbel
-opost -onlcr
-isig -icanon -iexten -echo -echoe -echok -echoctl -echoke
It is annoying because I have to add :
os.system("stty -F /dev/ttymxc6 opost")
In my code to make it work and this takes around 11ms which is pretty long for my application...
How can I remove this "opost" flag from pyserial to make it faster ?
pySerial clears the OPOST flags to achieve RAW output. Post processing could otherwise change CR/LF again and/or add unwanted delays or fill characters to the output. All of that is posix specific and not cross platform, so pySerial selects the RAW mode.
@zsquareplusc So it means this post processing make changes that break my modbus communication ? Do you have an idea where this post processing is made ?
Can I ask if this is related to this: https://github.com/raspberrypi/linux/issues/6189 ?