Question

im just looking for how to send/ write date to pc over serial port from arduino..vice versa.

I have few Question to ask after taking so much time and couldn't figure it out myself. I hope you guys can guid me please.

First, i found i can use Serial.println() function to send some data then, on the pc side, it just checks and reads the port (/dev/tty..). But, how does this process actually work under the hood? So, if you use serial.println() it knows about where to write?

Second i also found it's something to do with UART communication.. But, inside Hardware.cpp file, i couldn't find any function call to the one for UART.

Third there is the code like extern HardwareSerial Serial; Then where is the definition of this Serial?

Fourth There seem to have ring buffer for serial buffer. So, when data is being sent then, what and who fill the data into this buffer inside Hardware.cpp?

please, forgive my silly question.. i'm just so curious about this..

Was it helpful?

Solution

As you know to compile the sketch you have o select your Arduino Board and a COM Port where it is plugged in. So from there the Board knows where to send the data. External to the USB port you have for exmaple on the mega with the digital pins 0 and 1. So one of this pins is for transmitting data (TX) and one is for receving data (RX).

2 and3) Yes it has something to do with UART namely with the RX and TX wires I wrote above.
The USB port definitions are in my case here:
C:\Program Files (x86)\Arduino\hardware\arduino\firmwares\atmegaxxu2
The print definitios are here:
C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino
and there are some library files where probably the class definitions for the UART is

4) for exmaple you call Serial.println("blabla"); the text "blabla" is pushed char by char into a ring buffer. if he board sends the text o the Serial Monitor on the PC than i empties its content respectively sends it content over the USB cable to the Terminal program (Serial Monitor). If you recevie data then again you fill up an ring buffer (Receive ring buffer)

For further information, I recommend you to read:
http://arduino.cc/de/Reference/Serial

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top