At Mon, 22 Jul 2019 00:16:58 -0700 (PDT) [email protected] wrote:

> 
> 
> 
> 
> Hi,
> 
> i am trying with c program for Uart peripheral like this :
> #include<termios.h>
> #include <unistd.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <fcntl.h>
> #include <errno.h> 
> #include <stdio.h>
> #include<stdlib.h>
> 
> void main (void)
> {
>          int file;
>      char buf[20];
>     size_t nbytes;
>     ssize_t bytes_written;
>     struct termios oldtio, newtio;
> 
> 
>     if ((file = open("/dev/ttyS1", O_RDWR | O_NOCTTY))<0)
>     {
>          printf("UART: Failed to open the file.\n");
>          return;
>      }
> 
> 
>     //save the current serial settings
>     tcgetattr(file, &oldtio);
> 
>     //clear the structure for new port settings
>     bzero(&newtio, sizeof(newtio));
> 
>     newtio.c_cflag = B9600 | CS8 | CREAD | CLOCAL;
>     newtio.c_iflag = IGNPAR | ICRNL;
> 
>     tcflush(file, TCIFLUSH);
>     tcsetattr(file, TCSANOW, &newtio);
> 
>     strcpy(buf, "This is a test\n");
>     nbytes = strlen(buf);
> 
>     while (1)
>      {
>         bytes_written = write(file, buf, nbytes);
>         sleep(10);
>      }
>         close(file);
> 
> 
>   }
> i am running the code in to one terminal using ./uart1.0 and checking the 
> output into one more terminal using 
> 
> debian@beaglebone:~$ minicom -D /dev/ttyO1 -b 9600
> 
> minicom is opening but not able to see the data, here i not did any 
> hardware connection on board.

OK you can't open the *same* serial port with two programs and see what is 
sent by one with the other.

> 
> what is problem , where is the mistake please tell me...
> 
> suggest me any hardware connections i need to connect..

Go back to your earlier set up and cross-wire the pins for UART1 and UART2 and
open minicom on /dev/ttyO2.

> 
> 

-- 
Robert Heller             -- 978-544-6933
Deepwoods Software        -- Custom Software Services
http://www.deepsoft.com/  -- Linux Administration Services
[email protected]       -- Webhosting Services
               

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/20190722120748.3BCAD26C0176%40sharky3.deepsoft.com.

Reply via email to