Hello. New here. Been struggling with an issue and hope this is the right place to get help. So here goes.
I'm trying to get a C++ application running on a computer to send data, eg. simple string, to arduino via the serial port. The host computer running the C++ program is Linux. I don't know if this is the proper way to 'talk' to Arduino from an external program, but I am writing to the Arduino device file : /dev/ttyACM0 as referenced in this post: Communicating with Arduino using C/C++ | Fascinating
I have my Arduino wired up with a LCD (non serial) display and it works fine as a standalone. I am trying to get the C++ program to send a string of text to the Arduino which will display the text on the LCD screen when it recieves it. Example: The C++ program writes "Hello World!" to device file /dev/ttyACM0. Arduino reads the Serial Port and displays "Hello World!" to the lcd.
This works fine, but only when the serial monitor on the IDE is open? I don't know why, but for some reason I have to have the serial monitor from the Arduino IDE open for this to work. If I have the serial monitor closed/not opened. It doesn't work.
I poked around and found out there are some issues with the permissions of /dev/ttyACM0 and who can use it. I tried changing permissions, adding myself to the dialout group, etc. but nothing seems to work.
Obviously, I would like the program to work without the need of having the Arduino IDE and it's serial monitor opened and running in the background. In an actual deployment, I wouldn't tell the customer they have to install the Arduino IDE and launch the serial monitor for it to work.
I've concluded there is something about the serial monitor that makes this whole thing work. What is it? I'm not skilled enough to check out the Arduino IDE source code, but obviously, something is triggered when the serial monitor is opened. eg. changes permissions to /dev/ttyACM0 or something like that.
note: If I just write to /dev/ttyACM0 directly via the command line, eg. sudo echo "hello world" > /dev/ttyACM0, w/o the arduino IDE or serial monitor running, it works. This command does prompt for my password and after I type it in, the string appears in the lcd (keep in mind, w/o the ide or serial monitor running). If I don't use sudo, eg. echo hello > /dev/ttyACM0, nothing happens. No output.
Another thing to note is that when I try to send data to the arduino via the C++ program or just writing directly to /dev/ttyACM0 without the IDE & serial monitor running is that I notice the RX led is blinking. Still no output on the lcd, but the RX led does blink, suggesting it is getting something.
Any help would be greatly appreciated.