mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2025-12-10 16:32:16 +08:00
- new modules/simulation directory to collect all simulators and related modules - new Tools/simulation directory to collect and organize scattered simulation submodules, scripts, etc - simulation module renamed to simulator_mavlink - sih renamed to simulator_sih (not a great name, but I wanted to be clear it was a simulator) - ignition_simulator renamed to simulator_ignition_bridge - large sitl_target.cmake split by simulation option and in some cases pushed to appropriate modules - sitl targets broken down to what's actually available (eg jmavsim only has 1 model and 1 world) - new Gazebo consistently referred to as Ignition for now (probably the least confusing thing until we fully drop Gazebo classic support someday)
56 lines
1.4 KiB
Python
Executable File
56 lines
1.4 KiB
Python
Executable File
import serial, time
|
|
|
|
|
|
port = serial.Serial('/dev/ttyACM0', baudrate=57600, timeout=2)
|
|
|
|
data = '01234567890123456789012345678901234567890123456789'
|
|
#data = 'hellohello'
|
|
outLine = 'echo %s\n' % data
|
|
|
|
port.write('\n\n\n')
|
|
port.write('free\n')
|
|
line = port.readline(80)
|
|
while line != '':
|
|
print(line)
|
|
line = port.readline(80)
|
|
|
|
|
|
i = 0
|
|
bytesOut = 0
|
|
bytesIn = 0
|
|
|
|
startTime = time.time()
|
|
lastPrint = startTime
|
|
while True:
|
|
bytesOut += port.write(outLine)
|
|
line = port.readline(80)
|
|
bytesIn += len(line)
|
|
# check command line echo
|
|
if (data not in line):
|
|
print('command error %d: %s' % (i,line))
|
|
#break
|
|
# read echo output
|
|
line = port.readline(80)
|
|
if (data not in line):
|
|
print('echo output error %d: %s' % (i,line))
|
|
#break
|
|
bytesIn += len(line)
|
|
#print('%d: %s' % (i,line))
|
|
#print('%d: bytesOut: %d, bytesIn: %d' % (i, bytesOut, bytesIn))
|
|
|
|
elapsedT = time.time() - lastPrint
|
|
if (time.time() - lastPrint >= 5):
|
|
outRate = bytesOut / elapsedT
|
|
inRate = bytesIn / elapsedT
|
|
usbRate = (bytesOut + bytesIn) / elapsedT
|
|
lastPrint = time.time()
|
|
print('elapsed time: %f' % (time.time() - startTime))
|
|
print('data rates (bytes/sec): out: %f, in: %f, total: %f' % (outRate, inRate, usbRate))
|
|
|
|
bytesOut = 0
|
|
bytesIn = 0
|
|
|
|
i += 1
|
|
#if (i > 2): break
|
|
|