summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Whitehorn <kd0aij@gmail.com>2014-11-02 16:46:41 -0700
committerMark Whitehorn <kd0aij@gmail.com>2014-11-02 16:46:41 -0700
commit26f809f669b1a9cee9c74014cf3a00d17fe7cd62 (patch)
tree0db21ecc56aaa93ca6b06652c4e04215ff128d37
parente448f541cc0861569472833960e52fd519280be2 (diff)
downloadpx4-nuttx-26f809f669b1a9cee9c74014cf3a00d17fe7cd62.tar.gz
px4-nuttx-26f809f669b1a9cee9c74014cf3a00d17fe7cd62.tar.bz2
px4-nuttx-26f809f669b1a9cee9c74014cf3a00d17fe7cd62.zip
branch master: add simple python program to exercise usb serial
-rw-r--r--nuttx/configs/stm32f4discovery/usbnsh/defconfig2
-rw-r--r--usbtest/usbacm.py55
2 files changed, 56 insertions, 1 deletions
diff --git a/nuttx/configs/stm32f4discovery/usbnsh/defconfig b/nuttx/configs/stm32f4discovery/usbnsh/defconfig
index 7712f3260..58b517098 100644
--- a/nuttx/configs/stm32f4discovery/usbnsh/defconfig
+++ b/nuttx/configs/stm32f4discovery/usbnsh/defconfig
@@ -279,7 +279,7 @@ CONFIG_STM32_SPI=y
# CONFIG_STM32_JTAG_FULL_ENABLE is not set
# CONFIG_STM32_JTAG_NOJNTRST_ENABLE is not set
CONFIG_STM32_JTAG_SW_ENABLE=y
-# CONFIG_STM32_DISABLE_IDLE_SLEEP_DURING_DEBUG is not set
+CONFIG_STM32_DISABLE_IDLE_SLEEP_DURING_DEBUG=y
# CONFIG_STM32_FORCEPOWER is not set
# CONFIG_ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG is not set
# CONFIG_STM32_CCMEXCLUDE is not set
diff --git a/usbtest/usbacm.py b/usbtest/usbacm.py
new file mode 100644
index 000000000..5c864532f
--- /dev/null
+++ b/usbtest/usbacm.py
@@ -0,0 +1,55 @@
+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
+