I think the problem is more going to be that you don't have a serial connection to the arduino. ie, if you look in the Arduino IDE, you assign a serial port to the application. When you upload your sketch, a connection is made, the arduino resets (by design) and your sketch is uploaded.
What it appears you are doing here is opening a new connection and sending the character (which is ASCII
) which in turn sends the arduino into reboot to look out for a sketch being uploaded.
I'm not familiar with popen
and maybe you can use it and keep the connection open and even monitor the data stream, but I would say instead of writing directly to the device as you've done, use an application that will initialise the port properly (ie open it and leave it open) so that you can continue to use/monitor it.
A quick google search has brought up Mike's PBX Cookbook which has some good info about it. I've personally used minicom
(a guide for installing minicom) and CoolTerm
, I have used Screen
but it was so long ago I don't remember why I moved on.
edit: I just followed the link submitted by the first commenter (sorry name not available in the edit screen), and although you've responded with "that's not it", it actually is, you just haven't realised it since your popen
command is actually opening the port and triggering the RTS mentioned in that post