I am not sure if I understand--please clarify. On Sun, Feb 8, 2015 at 11:25 AM, oli4gate <[email protected]> wrote: > Hi, > > over the uart port I would like to send out following hexadecimal string > C5C301000000000076. ... > unsigned char tx_buf[9] = > {0xC5,0xC3,0x01,0x00,0x00,0x00,0x00,0x00,0x76}; //unsigned is 0<>255 signed > is -128<>127 > unsigned char *p_tx_buf = &tx_buf[0]; //points to the first element of > the tx_buf > > int fd; > > //open uart2 for tx/rx, not controlling device > if((fd = open("/dev/ttyO4", O_RDWR | O_NOCTTY | O_NDELAY)) < 0) > printf("Unable to open uart2 access .\n"); > else > printf("uart2 opened succesfully.\n"); > > if(write(fd,&tx_buf,sizeof(tx_buf))<0)
Ok, so you are not sending the hex string, but rather the binary values. I never ran it this way so I am not sure what might prevent it from working this way, but the following stack overflow discussion might be helpful: http://stackoverflow.com/questions/506805/binary-data-over-serial-terminal > printf("ERROR : tx not send.\n"); > else > for(unsigned int i = 0; i < sizeof(tx_buf); ++i) > { > std::cout << std::hex << (int)tx_buf[i]; > } > printf(" : tx send \n"); You do realize that the 'else' block contains just the for() {} loop and not the printf statement? (your indentation seems to indicate otherwise) I recommend using curly braces always even if the conditional block has just one statement. -- 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]. For more options, visit https://groups.google.com/d/optout.
