c++ - Incorrect serial port input/output -
i attempting activate serial port on beaglebone black , have connected tx rx. wrote test program. in it, setup serial port 1152000 baud , no parity according found @ how open, read, , write serial port in c. below main function:
int main(void) {     char *portname = "/dev/ttyo4";      int fd = open (portname, o_rdwr | o_noctty | o_sync);     if (fd < 0)     {         printf ("error %d opening %s: %s", errno, portname, strerror (errno));         return 0;     }      set_interface_attribs (fd, baud_rate, 0);     set_blocking (fd, 0);      while (true)     {         write (fd, "hello!\n", 7);         char buf [100];         int n = read (fd, buf, sizeof buf);         std::cout << buf;         std::cout.flush();         sleep(1);     }      return 0; } when run it, read on serial port rx, isn't hello, "รน¶" instead. can tell me why happening??
kind regards
cornel
 
 
Comments
Post a Comment