SendData - Terrapin-Rocket-Team/SRAD-Avionics GitHub Wiki

Home/Documentation/StateTest/SendData

Send Data Script (SendData.py)

This script is used to send fake data to the FC for testing purposes. It is used in conjunction with the StateTest class to test the State class. The script reads in data from a CSV file, sends it to the FC, and then records the data that the FC sends back, both printing it and writing it to a file.

How to use

You need to have Python and the Python package colorama installed. If you don't have Python, you can download it from here. If you don't have colorama, you can install it with pip install colorama from a terminal (after Python is installed).

See The State Testing Class for how to use this script in conjunction with the StateTest class.

Inner Workings

The COM port variable at the top needs to be changed to the COM port that the FC is connected to. This can be found in the PlatformIO terminal when code is uploaded. It cannot run at the same time as the PIO Serial monitor, as they both use the same COM port and are thus refused access if one already has it.

serialPort = 'COM6'  # Use the correct port for the Arduino -- CHANGE THIS ONE
baudRate = 9600  # Match the baud rate to the Arduino's. Shouldn't need to be changed.
dataFile = 'fake_data.csv' # The file to read data from
output = 'test_results.csv' # The file to write data to

It essentially opens the file and sends data one line at a time, waiting for a valid response from the FC before sending the next line. This is denoted by a line starting with [][] being returned from the FC. This is a signal that the FC is ready for the next line of data. Other lines are printed to the console but not acted upon.

See Also

⚠️ **GitHub.com Fallback** ⚠️