У меня есть вопросы по поводу получения необработанных данных от KS-CM01 (напальцевого датчика SpO2). Я отправил «aa 55 50 03 02 02 c5» на KS-CM01 через последовательный порт. К сожалению, я все еще получил данные типа 0x01, которые были нормализованы. Кто-нибудь использовал этот датчик, может мне помочь? Спасибо! Вот код.
Код: Выделить всё
# send command to the KS-CM01
command = "aa5550030202c5"
command_byte = bytes.fromhex(command)
ser.write(command_byte)
sleep(5)
data = ser.read_all().hex()
if command in data:
print("Setup Successful! \n")
else:
print("Setup failed! \n")
# get data from it
text = ""
while True:
data = ser.read_all() # str
if data == b'':
continue
text = text + data.hex()
text_split = text.split("aa55")
num_text = len(text_split)
if num_text < 2:
continue
else:
text = text_split[num_text-1]
for i in range(num_text-1):
response_ = text_split[i]
if response_ == "":
continue
response_ = "aa55"+response_
response_ = re.findall(r'.{2}', response_)
print(response_)
Подробнее здесь: https://stackoverflow.com/questions/788 ... or-ks-cm01