Hi Graham Thanks for replying I am using UART 4 , i.e ttyO4 P2.5 and P2.7. Further, as I understand, ttyO4 is enabled on my device by default since I am able to see it on device tree.
When the string to send is "HIGH", I am receiving strings such as IGH @IGH H And so on at each read. I have shorted Rx and Tx so possibility of hardware noise is ruled out. What else can I look at? Help would be deeply appreciated Regards On Tue, 2 Mar, 2021, 11:42 Graham Stott, <[email protected]> wrote: > Which Pins are you using for UART4 rcv and have you set the PIN mux > correctly for that PIN? > > > > *From:* [email protected] [mailto:[email protected]] > *On Behalf Of *Piyush Raj ae19m009 > *Sent:* Monday, March 01, 2021 6:30 PM > *To:* BeagleBoard <[email protected]> > *Subject:* [beagleboard] POCKETBEAGLE: UART Help - Garbage data along > with requisite data > > > > I am implementing UART using Pocketbeagle wherein i am trying to send > simple strings over UART . I have written a code for loopback testing of > UART-4 in PB. for a logic Low on P2.1 i am sending String "LOW" and "HIGH" > for vice versa. However i am getting garbage data along with the requisite > strings. sometimes all the received data is missing or broken. I tried to > work at various baud rates (600, 9600,115200) but of no help. > > Am i doing any basic mistake. need guidance from community. (I worked with > AVR and Arduino UART in the past and never faced such problem) > > > > Further, i also tried to dump the received data in a text file( to rule > out possibility of terminal baud rate mismatch), but results did not change. > > > > My code is below: > > > > > > #include<fstream> > > #include<iostream> > > #include <string.h> > > #include <fcntl.h> > > #include <termios.h> > > #include<unistd.h> //for usleep > > #include"GPIO.h" > > using namespace exploringBB; > > using namespace std; > > > > int main() > > { > > GPIO outLogicSupply(60); outLogicSupply.setDirection(OUTPUT); > > GPIO inLogicSupply(59); inLogicSupply.setDirection(INPUT); > > > > int file,count; > > char transmit[6]; > > char receive[10]; > > int bytes_written,read_code;int count1=1; > > //////////////// OPENING UART4 ON POCKETBEAGLE ///////////////////// > > printf("UART: Transmission Started.\n"); > > if ((file = open("/dev/ttyO4", O_RDWR | O_NOCTTY | O_NDELAY))<0) > > { > > perror("UART: Failed to open the device.\n"); > > return -1; > > } > > else > > { > > printf("UART: Opened file successfully\n"); > > } > > ///////////////////////////////////////////////////////////////////// > > > > /////////////// SETTING UP UART OPTIONS /////////////////////////// > > struct termios options; > > tcgetattr(file, &options); > > options.c_cflag = B9600 | CS8 | CREAD | CLOCAL; > > options.c_iflag = IGNPAR | ICRNL; > > tcflush(file, TCIFLUSH); > > fcntl(STDIN_FILENO, F_SETFL, O_NONBLOCK); // make reads non-blocking > > tcsetattr(file, TCSANOW, &options); > > > > cout << "The value of the input is: "<< inLogicSupply.getValue() << > endl; > > > > > > while(1) > > { > > > > if(inLogicSupply.getValue()==1) > > > > { > > strcpy(transmit,"HIGH\n"); > > outLogicSupply.setValue(HIGH); > > > > } > > else > > > > { > > strcpy(transmit,"LOW\n"); > > outLogicSupply.setValue(LOW); > > } > > > > bytes_written = write(file, &transmit,6); > > sleep(1); > > read_code= read(file,receive,10); > > if(bytes_written>0 && read_code>0 ) > > { > > receiveFile<<count1<<"sec - "<<receive; > > cout<<count1<<"sec - "<<receive; > > > > } > > count1++; > > sleep(0.01); > > } > > > > /////////////////////////////////////////////////////////////// > > receiveFile.close(); > > close(file); > > > > return 0; > > } > > -- > 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/99530b73-a474-410b-8583-4d0327d32d35n%40googlegroups.com > <https://groups.google.com/d/msgid/beagleboard/99530b73-a474-410b-8583-4d0327d32d35n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > -- > For more options, visit http://beagleboard.org/discuss > --- > You received this message because you are subscribed to a topic in the > Google Groups "BeagleBoard" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/beagleboard/DhW9SvsyCPI/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/beagleboard/000201d70f2a%24edd15100%24c973f300%24%40comcast.net > <https://groups.google.com/d/msgid/beagleboard/000201d70f2a%24edd15100%24c973f300%24%40comcast.net?utm_medium=email&utm_source=footer> > . > -- 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/CAD20Z3w0rcTxGwOz1uKtZuqfBpYj%2Bz8TJ%3DBj%3DDrdmb2-9bQXbw%40mail.gmail.com.
