本文介绍了如何构建十六进制命令并将其发送到电视的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一台 NEC PX-42VM5HA 等离子电视,我试图用连接的计算机控制它.我有数据表,其中显示了控制电视和协议信息的所有代码.我不确定如何在 python 中构建正确的数据结构来发送 HEX 控制代码.下面是电源控制代码和通信协议.
I have an NEC PX-42VM5HA plasma tv that I am trying to control with the connected computer. I have the data sheet that shows all the codes to control the tv and the protocol information. I am unsure how to build the right data structure in python to send the HEX control codes. Below is the Power Control Codes and the Communications Protocol.
Communication Protocol: Interface: RS-232C Communication: Asynchronous Baud Rate: 9600 Data Length: 8bits Parity: Odd Stop Bit: 1bit Communication Code: Hex Power Control Codes ON 9FH 80H 60H 4EH 00H CDH OFF 9FH 80H 60H 4FH 00H CEH这是我到目前为止的代码:
Here is the code I have so far:
import time import serial ser = serial.Serial( port='COM1', baudrate=9600, parity=serial.PARITY_ODD, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS ) ser.close() ser.open() ser.isOpen() ON=bytearray([0x9FH,0x80H,0x60H,0x4EH,0x00H,0xCDH]) OFF=bytearray([0x9FH,0x80H,0x60H,0x4FH,0x00H,0xCEH]) ser.write(OFF) time.sleep(30) ser.write(ON) ser.close() 推荐答案将控制代码写成字符串
ON = "\x9f\x80\x60\x4e\x00\xcd" ser.write(ON)更多推荐
如何构建十六进制命令并将其发送到电视
发布评论