如何构建十六进制命令并将其发送到电视

编程入门 行业动态 更新时间:2024-10-28 14:23:14
本文介绍了如何构建十六进制命令并将其发送到电视的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一台 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)

更多推荐

如何构建十六进制命令并将其发送到电视

本文发布于:2023-07-13 22:19:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1102473.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:发送到   命令   电视   并将其   十六进制

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!