LibSerialPort.jl
LibSerialPort.jl copied to clipboard
set_flow_control() not working on Linux Mint 19 Cinnamon
I am writing a small module to send inputs and save outputs to/from an Arduino 256 mega. I had trouble resetting the Arduino upon opening the serial port. The following code works on a Windows 10 machine, not on Linux Mint 19 Cinnamon:
port = SerialPort(Arduino_dict[Arduino_port])
open(port)
LibSerialPort.set_speed(port,115200)
LibSerialPort.set_flow_control(port, rts = SP_RTS_ON,dtr = SP_DTR_ON)
I am using Julia v1.7.2 and LibSerialPort v0.5.2
What exactly was the difference in behaviour between the Windows and Linux version?
What do you mean by "trouble resetting the Arduino"?
How did the expected and actual behaviour differ?
Were you able to check what was going on on the serial-port wires (with an oscilloscope or a logic analyzer)?
What exactly was the difference in behaviour between the Windows and Linux version? In the windows version the Arduino resets as expected, in the Linux it doesn't
What do you mean by "trouble resetting the Arduino"? See above
How did the expected and actual behaviour differ? I expected that using LibSerialPort.set_flow_control(port, rts = SP_RTS_ON,dtr = SP_DTR_ON) will reset arduino
Were you able to check what was going on on the serial-port wires with a scope of logic-analyzer? No, my ignorance. Can you explain to me/point me to an explanation of what a logic-analyzer is and how to do it?
My suspicion is that you need an edge on either the RTS or the DTR wire to reset the Arduino, but you are just setting a level once. Therefore, the effect you get may simply depend on what level these wires had already before you run your script. For a proper reset, I would have expected that you need to set one level, then wait briefly, and then set the opposite level, such that you actually get a transition. So it's possible that your script worked on Windows only by chance.
A logic analyzer is a test device designed to visualize the logic level on several wires as a function of time. It's a useful debugging tool for digital-hardware projects, similar to an oscilloscope, but with many digital rather than just a few analogue input channels. See e.g. the sigrok hardware list for examples of some basic USB ones.
Thank you very much for the explanation, I will try to procure one. In the meantime, I understand the logic of what you are saying but do you have any suggestions on how to use LibSerialPort to follow your advice (you need to set one level, then wait briefly, and then set the opposite level, such that you actually get a transition)?
Something like
LibSerialPort.set_flow_control(port, rts = SP_RTS_OFF,dtr = SP_DTR_OFF)
sleep(0.1)
LibSerialPort.set_flow_control(port, rts = SP_RTS_ON,dtr = SP_DTR_ON)
perhaps? (I don't know which way round you need the edge, i.e. on-to-off or off-to-on, and if you need it on both wires or just one.)
Did you resolve the issue or do you have a more detailed diagnosis of the problem?