How to communicate with Arduino over its serial interface in C ++ on Linux?

I have an RFID reader connected to an Arduino board. I would like to connect to it through its serial interface, and whenever an RFID reader passes a signal (when it reads an identifier (RF)), I would like to get it in my C ++ program.

I already have code for simple printing RFID to serial from Arduino.

What I do not know how to read it from C ++ on Linux?

I looked at libserial , which looks simple. However, how can I make a C ++ program respond to a signal and then read the RFID, rather than listen constantly? It's necessary?

EDIT: In most of the examples I read, the program (C ++) sends the input and gets the result. I just want to listen and get results from Arduino.

+7
c ++ linux serial-port arduino rfid
source share
4 answers

I found the Boost :: Asio library, which reads asynchronously from serial interfaces. Boost :: Asio Documentation

+3
source share

On unix, you use the select () call to wait for input. The select () call acts like a dream - without using a CPU until the kernel receives a hardware interrupt and calls select ().

http://tldp.org/HOWTO/Serial-Programming-HOWTO/index.html

+6
source share

In the Communications section of the interface section of the Arduino Playground, there are several examples of interaction, including one with Arduino as Linux TTY.

Try the Syntax and Software Forum and Software Development on the Arduino website. In the past, issues of interaction with many languages ​​and computers have been discussed.

Finally, check out Processing and Wiring . The Arduino IDE is based on the processing language, and the wiring environment and dev board are associated with the Arduino. Both sites have more examples and links to even more resources.

Edit: I only realized that I did not answer your real question. These are all common communication resources, but some may have hints on how to warn the computer about the introduction of a new RFID.

+1
source share

Hi, I created a Simple Library for this: cArduino https://github.com/ranma1988/cArduino C ++ can find an automatic search for the Arduino connecting port, read, write

0
source share

All Articles