I am attempting to activate a serial port on the Beaglebone black and have connected the TX to the RX. I wrote a test program. In it, I setup my serial port to 1152000 baud and no parity according to help I found at how to open, read, and write from serial port in C. Below is my 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 I run it, I read something on the serial port RX, but it isn't hello, it is "ù¶" instead. Can someone tell me why this is happening??
Kind regards
Cornel