简体   繁体   中英

Serial Mac OS X constantly freezes/locks/dissappears for USB to Arduino

I have a problem with my C++ code running in Xcode with both the AMSerial library as well as the generic C (ioctl, termios).

After a fresh restart, my application works well but after I "kill" the program the Serial (I think) is not released.

I have checked my open files under /dev and have killed the connection to serial USB from there, but my C++ still can't open the USB port.

I have narrowed this down to being a low level Mac OS X issue, regarding blocking the port indefinitely, regardless of closing it using the aforementioned libraries.

Just for context, I'm trying to send numbers through my USB port, serially to an Arduino Duemilanove at 9600 baud. Running Serial Monitor in Arduino is perfectly fine, however, running through a C++ application it freezes up my computer, occasionally, my mouse/keyboard freeze up: requiring a hard reset.

How can this problem be fixed? It seems like Mac OS X is not USB friendly!

Sorry, answered my own question a while back! After I connect to the Arduino, I have to include a sleep(2) to ensure the serial is actually connected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM