UART Serial Connection
Nov 4, 2013 at 4:27am UTC
Hi, I am trying to implement a code that is able to receive input from a serial communication. I believe that it is possible to do this using fstream, but so far I have been unsuccessful. The code below should echo everything received on screen:
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 #include <iostream>
int main( int argc, const char * argv)
std::string msg = "";
std::cout << "Hello, World!\n";
std::fstream file( "/dev/tty.usbserial-A800F2GZ");
file >> msg;
std::cout << "Response: " << msg << std::endl;
Currently using: Mac OS X 10.8.5, Xcode 5
Nov 5, 2013 at 1:42am UTC
It's been a number of years, but on Linux I have not used std::fstream to talk to serial. I have used code similar to:
The devices were:
and I always had to change the permissions on them to allow non-root access.
Sorry I think you will have to ask Mr Google.
Topic archived. No new replies allowed.