test environment
Window 10, Python 3.8.6
requirements library
numpy pyserial
Routines
h2>
#创建日期:2020年10月10日
#版本:初版
#此程序对应北醒TF系列默认配置下串口版本有效
#此程序只提供参考和学习
# -*- coding: utf-8 -*-
import serial.tools.list_ports
import time
import numpy as np
ser = serial.Serial()
ser.port = 'COM13' #设置端口
ser.baudrate = 115200 #设置雷达的波特率
def getTFminiData():
while True:
count = ser.in_waiting #获取接收到的数据长度
if count > 8:
recv = ser.read(9)#读取数据并将数据存入recv
#print('get data from serial port:', recv)
ser.reset_input_buffer()#清除输入缓冲区
if recv[0] == 0x59 and recv[1] == 0x59: # python3
distance = np.int16(recv[2] + np.int16(recv[3] << 8))
strength = recv[4] + recv[5] * 256
print('distance = %5d strengh = %5d' % (distance, strength))
ser.reset_input_buffer()
if recv[0] == 'Y' and recv[1] == 'Y': # python2 //此处标示出文件读取成功
lowD = int(recv[2].encode('hex'), 16)
highD = int(recv[3].encode('hex'), 16)
lowS = int(recv[4].encode('hex'), 16)
highS = int(recv[5].encode('hex'), 16)
distance = np.int16(lowD + np.int16(highD << 8))
strength = lowS + highS * 256
print('distance = %5d strengh = %5d' % (distance, strength))
else:
time.sleep(0.005) #50ms
if __name__ == '__main__':
try:
if ser.is_open == False:
try:
ser.open()
except:
print('Open COM failed!')
getTFminiData()
except KeyboardInterrupt: # Ctrl+C
if ser != None:
ser.close()
#创建日期:2020年10月10日
#版本:初版
#此程序对应北醒TF系列默认配置下串口版本有效
#此程序只提供参考和学习
# -*- coding: utf-8 -*-
import serial.tools.list_ports
import time
import numpy as np
ser = serial.Serial()
ser.port = 'COM13' #设置端口
ser.baudrate = 115200 #设置雷达的波特率
def getTFminiData():
while True:
count = ser.in_waiting #获取接收到的数据长度
if count > 8:
recv = ser.read(9)#读取数据并将数据存入recv
#print('get data from serial port:', recv)
ser.reset_input_buffer()#清除输入缓冲区
if recv[0] == 0x59 and recv[1] == 0x59: # python3
distance = np.int16(recv[2] + np.int16(recv[3] << 8))
strength = recv[4] + recv[5] * 256
print('distance = %5d strengh = %5d' % (distance, strength))
ser.reset_input_buffer()
if recv[0] == 'Y' and recv[1] == 'Y': # python2 //此处标示出文件读取成功
lowD = int(recv[2].encode('hex'), 16)
highD = int(recv[3].encode('hex'), 16)
lowS = int(recv[4].encode('hex'), 16)
highS = int(recv[5].encode('hex'), 16)
distance = np.int16(lowD + np.int16(highD << 8))
strength = lowS + highS * 256
print('distance = %5d strengh = %5d' % (distance, strength))
else:
time.sleep(0.005) #50ms
if __name__ == '__main__':
try:
if ser.is_open == False:
try:
ser.open()
except:
print('Open COM failed!')
getTFminiData()
except KeyboardInterrupt: # Ctrl+C
if ser != None:
ser.close()
output as follows:
distance = 38 strengh = 8685
distance = 39 strengh = 8522
distance = 38 strengh = 8441
distance = 38 strengh = 8383
distance = 38 strengh = 8355
distance = 38 strengh = 8323
distance = 38 strengh = 8290
distance = 38 strengh = 8261
distance = 39 strengh = 8241
distance = 39 strengh = 8231
distance = 38 strengh = 8234
div>
Read More:
- tf.gradients is not supported when eager execution is enabled. Use tf.GradientTape instead.
- raise RuntimeError(“tf.placeholder() is not compatible with “ RuntimeError: tf.placeholder() is not
- In tensorflow tf.reduce_ Mean function
- Tensorflow in function tf.Print Method of outputting intermediate value
- Tensorflow with tf.Session The usage of () as sess
- tf.one_ How to use hot ()
- tf.layers.conv1d Function analysis (one dimensional convolution)
- tf.contrib.layers .xavier_ Initializer function usage
- After the new video card rtx3060 arrives, configure tensorflow and run “TF. Test. Is”_ gpu_ The solution of “available ()” output false
- Tensorflow tf.train.exponential_ Decay function (exponential decay method)
- Solve the problem of using in tensoft 2. X tf.contrib.slim No module named appears in the package: tensorflow.contrib problem
- Not creating XLA devices, tf_xla_enable_xla_devices not set
- PX4 Offboard routine running sequence
- Windows10解决ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed
- Attributeerror: ‘STR’ object has no attribute ‘decode’ solution: the pro test is successful.
- Solution to flash back of MacBook Pro open software of M1 chip
- Can’t find Python executable “D:\python3\python.exe”, you can set the PYTHON env variable.
- VTK beginner 1, configuration of pro file
- The software of Final Cut Pro x 10.5 failed to open, and it flashed back directly.
- Tensorflow UnknownError (see above for traceback): Failed to get convolution algorithm. This is pro