Python script for displaying serial data in a GUI format, plus displaying a gif or movie

Job ID: 35695867

Budget: $30 – $250 USD

I need a Python script for linux that receives ~40 datapoints via the serial port then displays the values on the screen. The displayed values should be updated each time a new stream of serial data is received. In the center of the screen a predefined animated gif or video (whatever is easiest) should play; this is decorative only and does not react or change based on the serial data. This should run on raspbian.

The attached pdf shows a basic layout for the display. Widths and sizes may be slightly adjusted as needed to fit data. Note the display is a 7" 800x480 screen so the text needs to be fairly large; the proportion shown in the ppt is approximately correct.

Serial data order is as shown, comma separated and sent at ~10hz. All values are floats. See pdf for where each data index should be displayed:

1: channel_1_pwm
2: channel_2_pwm
3: channel_3_pwm
4: channel_4_pwm
5: thro_des
6: roll_des
7: pitch_des
8: yaw_des
9: GyroX
10: GyroY
11: GyroZ
12: AccX
13: AccY
14: AccZ
15: roll_IMU
16: pitch_IMU
17: yaw_IMU
18: roll_PID
19: pitch_PID
20: : yaw_PID
21: s1_command_PWM
22: s2_command_PWM
23: s3_command_PWM
24: s4_command_PWM
25: loop rate
26: s1_accel_counter
27: s2_accel_counter
28: s3_accel_counter
29: s4_accel_counter
30: Gain select
31: Roll kp
32: Roll kd
33: Roll ki
34: Pitch kp
35: Pitch kd
36: Pitch ki
37: Yaw kp
38: Yaw kd
39: Yaw ki
40: Arm state

As an example, the following code is currently effective at reading the serial stream and displaying some of it simply. I am not skilled with python so while this code works, it is not tolerant of serial hiccups, incomplete data, etc.

ser = serial.Serial ("/dev/serial0", 115200) #Open port with baud rate
recieved_data=''
datas=["0"]

try:
while True:
received_data = ser.readline() #read serial port
datas=str(received_data).split(',')

if len(datas)>=40:
print('Desired state (deg): {:+.2f},{:+.2f},{:+.2f},{:+.2f}'.format(float(datas[4]),float(datas[5]),float(datas[6]),float(datas[7])))
finally:
Related categories: Python Linux Software Architecture Shell Script