0

So I am trying to make a Mac OSX program with Cocoa that will be able to control my Arduino via serial. I currently have the C command

popen("echo 7 > /dev/cu.usbmodem1411", "r");

to try to send the number 7 over serial to the Arduino. I know that the path /dev/cu.usbmodem1411 is correct because the Arduino is responding, however it seems to "crash" or simply restart whenever this command is received from the Mac. Sorry this may be a question for StackOverflow, but I thought I would start here.

woakley5
  • 119
  • 2

1 Answers1

0

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

Madivad
  • 1,372
  • 8
  • 26