So I am looking into reducing the read time which from what I've seen on the forums seems to be done by sending binary rather than ascii data.,I am reading a pressure sensor so the analog values can go up to 1023 and then I am sending those values to a python gui running on tkinter. The biggest bottle neck was the reading time for the incoming data. I am able to run the communication between the two fast enough when I am performing no other tasks that was the first thing I did like you suggested it's just that when I add all the other tasks in is when I am unable to read fast enough. So I am looking into reducing the read time which from what I've seen on the forums seems to be done by sending binary rather than ascii data.,emg184: Why cant I read in data from the serial port using a bash script. Linux Send Binary Data To Serial Port Serial Port Using. I currently use Serial.print() to send the data and I am unable to read it fast enough,I am able to run the communication between the two fast enough when I am performing no other tasks that was the first thing I did like you suggested it's just that when I add all the other tasks in is when I am unable to read fast enough. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own. If I send the following binary data, then read only ‘01’.Ġ1 00 76 98 99 77 FF FF E6 6F 0D => Read only 01Ġ1 01 76 98 99 77 FF FF E6 6F 0D => Read correctly.Ġ2 00 76 98 99 77 FF FF E6 6F 0D => Read only 02Ġ2 01 02 C8 1C 62 5B 01 95 CF 0D => Read correctly.Ĥ1 54 2B 43 43 4C 4B 3F 0D 0A => Read correctly.I need to increase the speed at which i am able to read data in using pyserial after looking through the forums I saw a few posts saying the fastest way to receive data would be by sending binary data. Note: use stty to configure serial port appropriately. file.bin is binary file, /dev/ttyPS0 is device representing serial port. If(read(fd, buf_rx, sizeof(buf_rx)) != -1) From the command line, for example: cat file.bin > /dev/ttyPS0. Printf("Error! Can't set attributes.\n") * Write the configuration to the termios structure*/ Here are the flags I am using / Open the serial port / sfd open (serialport, ORDWR ONONBLOCK) How do I configure the port to work in binary mode Thanks for helping. a 0xD is getting inserted before 0xA It seems to me that the port is configured to work in text mode, not in binary. Tty.c_cflag
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |