I am using multiple TX2 boards to do high speed object tracking, each TX2 is connect to a camera.
I combine two TX2 as a stereo camera system.
Cameras will be triggered at the same time and send the image to TX2 for image processing.
After processing, I will get the coordinate(x, y) of object in the image, image counter and a flag to stand that I detect the object or not.
In order to form a stereo camera system, one TX2 has to send the information to another TX2 by serial port (ttyTHS2).
And this part confuse me a lot.
The serial port works correctly for most of the time, while in some timing, the serial port will give me the wrong message.
I am using thread with while loop to keep waiting and reading for serial port.
while(1) {
get_time1
read(...)
get_time2
calculate the time interval ( time2 - time1 )
process the message I receive
save the message and time interval into file for debug
send to another thread to do opencv triangulatePoints
}
I got 3 different types of the wrong message in different tests.
the following message will in the format of (# while loop counter, x y image_counter object_flag. , time interval)
Type 1:
# 774 , 284 361 774 1. , 0.003909 # 775 , 283 361 775 1. , 0.004055 # 776 , 284 361 776 1. , 0.003854 # 777 , 284 361 776 , 0.004098 # 778 , 777 1.1 , 0.000002 # 779 , 285 361 778 1. , 0.003771 # 780 , 284 361 779 1. , 0.003956 # 781 , 284 361 780 1. , 0.003952 # 782 , 284 361 781 1. , 0.003951
Type 2:
# 665 , 284 291 665 1. , 0.004000 # 666 , 284 291 666 1. , 0.003923 # 667 , 284 291 667 1. , 0.003948 # 668 , 284 291 668 1 , 0.003917 # 669 , 1.4 , 0.000034 # 670 , 284 291 669 1. , 0.003862 # 671 , 283 291 670 1. , 0.004009 # 672 , 284 291 671 1. , 0.004011 # 673 , 284 291 672 1. , 0.003938
Type 3:
# 610 , 216 286 610 1. , 0.003913 # 611 , 222 276 611 1. , 0.003957 # 612 , 217 285 612 1. , 0.003973 # 613 , 217 286 613 1. , 0.003991 # 614 , 216 286 614 1.216 286 615 1. , 0.009115 # 615 , 217 286 616 1.216 286 615 1. , 0.002787 # 616 , 216 286 617 1.216 286 615 1. , 0.003928 # 617 , 217 286 618 1.216 286 615 1. , 0.003980 # 618 , 216 286 619 1.216 286 615 1. , 0.003935
I am using a dot to represent the end of each message, and I trigger the cameras every 4 ms, thus the message should came with period around 4 ms.
From the above messages, type 1 and type 2 missing the dot, and one message is being cut into two parts.
And observing the time interval, it can be found out that the second message came right after the first one.
Also, there is a strange number, which is not part of my message came after the dot.
From type 3, the serial buffer keeps copying one section of message, then it keeps doing so till the end of my program.
Once a time, I have try with
dmesg | grep tty
and i got the message
RxData DMA copy to tty layer failed
This made me worry about whether the error came from memory copying stage or not.
Now, I am using the 8n1 and baudrate 115200.
Actually, this error won’t appear every time.
It seems that there is no rules that the error occurred frequency can be observed.
Sometimes it appears two times in one running of program, and sometimes the program works well in consecutively 5 times.
It really bother me a lot since I run the same code successfully on TK1 for the past time being.
Please help with this strange problem.