Hi all. I have used Arduino mega for several projects and one constant reliable feature is that it resets if one opens the serial monitor or opens a USB connection via python or similar programmes.
Now, this has stopped working, the only difference from the past is that I am testing without using an external 5V power source; only the USB.
Can this be the reason? I did not find any similar issue online. Only, people that asked how to stop the reset, which I actually need it to work.
I am using Arduino IDE 1.8.12 for the sketch, Julia 1.7.2 with LibSerialPort v0.10.4 for programming. The operating system is Linux Mint 19 Cinnamon v3.8.9.
I did not try, nor I ever used other programs for my Arduino's sketches (except some python).
I did some digging and the issue appears only in a specific sequence.
If I load my sketch on Arduino IDE and only use the serial monitor to communicate input everything works as expected, meaning the programme resets every time I open the serial monitor.
On the contrary, if I use Julia 1.7.2 with LibSerialPort v0.10.4 the first time that I open the SerialPort communication the sketch resets, takes the input and proceeds, but from that moment onwards it stops resetting (close-open port from programming, or close-open serial monitor from IDE)
Does LibSerialPort have options to enable/disable DTR/RTS when the serial port is opened.
Have your previous experiences been with the same OS? Maybe there was an OS update (including the kernel module).
Is this a different Mega board (e.g. one with CH340 instead of 16U2)?
Julia is the issue Thank you for the pointer @sterretje . The default setting of LibSerialPort package switches off DTR/RTS, it must be a breaking change not very well highlighted.
To solve the issue one has to do the following on Julia 1.7.2 with LibSerialPort v0.10.4
using LibSerialPort
port = SerialPort(Arduino_address::String)
open(port)
LibSerialPort.set_speed(port,115200)
LibSerialPort.set_flow_control(port, rts = SP_RTS_ON,dtr = SP_DTR_ON)
Can you answer this question, please. I've never heard of it.
And something is brilliant in what you're using (probably LibSerialPort) on Linux. I thought that changing the behaviour of the opening of the serial port in Linux actually required a hack of a kernel module. As you said, most people want to suppress the reset behaviour and I'm often one of them.
My apologies I thought you were making a pun with the name of the language. you can find Julia's documentation at the link posted by @in0 . Using the LibSerial port package is very easy. After installing Julia use the package manager to add LibSerialPort.
Julia is a very straightforward language if you need that functionality it's worth it and easy to try