The invention is applicable to the field of communication technology and provides a control method, device and host computer of a serial interface, wherein the control method of the serial interface includes: sending data to an external device through the serial interface, and monitoring the response data sent by the external device; if the response is heard within a predetermined time; The data continues to communicate with the external device in accordance with the serial communication protocol; if the response data is not monitored within a predetermined time, the serial interface is used as an input interface for receiving the input instructions of the external device. The invention can control the use of the serial interface according to the response of the external device, thereby compatible with a variety of external devices, improving the utilization rate of resources, and having strong practicability and practicability.
【技术实现步骤摘要】
一种串行接口的控制方法、装置及主机
本专利技术涉及通信领域,尤其涉及一种串行接口的控制方法、装置、主机及计算机可读存储介质。
技术介绍
在电子产品中,通常会将每种接口独立出来,通过采用交互接口的方式来兼容多种外接设备,暂时不用的扩展接口往往会处于闲置状态,极大地占用了I/O资源。
技术实现思路
鉴于此,本专利技术实施例提供了一种串行接口的控制方法、装置及主机,可以根据外部设备的应答来控制所述串行接口的使用,从而兼容多种外部设备,提高了资源的利用率。本专利技术实施例的第一方面提供了一种串行接口的控制方法,所述主机包括一串行接口,所述主机通过所述串行接口与外部设备连接,所述方法包括:通过所述串行接口向外部设备发送数据,并监听所述外部设备发送的应答数据;若在预设时间内监听到所述应答数据,则继续按照串口通讯协议与所述外部设备通信;若在预设时间内未监听到所述应答数据,则将所述串行接口作为一输入接口,用于接收所述外部设备的输入指令。本专利技术实施例的第二方面提供了一种串行接口的控制装置,包括:发送模块,用于通过所述串行接口向外部设备发送数据,并监听所述外部设备发送的应答数据;第一处理模块,用于若在预设时间内监听到所述应答数据,则继续按照串口通讯协议与所述外部设备通信;第二处理模块,用于若在预设时间内未监听到所述应答数据,则将所述串行接口作为一输入接口,用于接收所述外部设备的输入指令。本专利技术实施例的第三方面提供了一种主机,包括:包括存储器,处理器及存储在存储器上并可在处理器上运行的计算机程序,上述处理器执行上述计算机程序时实现上述第一方面提及的方法。本专利技术实施例的第 ...
【技术保护点】
1.一种串行接口的控制方法,其特征在于,应用于主机,所述主机包括一串行接口,所述主机通过所述串行接口与外部设备连接,所述方法包括:通过所述串行接口向外部设备发送数据,并监听所述外部设备发送的应答数据;若在预设时间内监听到所述应答数据,则继续按照串口通讯协议与所述外部设备通信;若在预设时间内未监听到所述应答数据,则将所述串行接口作为一输入接口,用于接收所述外部设备的输入指令。
【技术特征摘要】
1.一种串行接口的控制方法,其特征在于,应用于主机,所述主机包括一串行接口,所述主机通过所述串行接口与外部设备连接,所述方法包括:通过所述串行接口向外部设备发送数据,并监听所述外部设备发送的应答数据;若在预设时间内监听到所述应答数据,则继续按照串口通讯协议与所述外部设备通信;若在预设时间内未监听到所述应答数据,则将所述串行接口作为一输入接口,用于接收所述外部设备的输入指令。2.根据权利要求1所述的方法,其特征在于,所述通过所述串行接口向外部设备发送数据,并监听所述外部设备发送的应答数据包括:在首次上电时通过所述串行接口向外部设备发送数据,并监听所述外部设备发送的应答数据。3.根据权利要求1所述的方法,其特征在于,所述串口通讯协议包括:R232串口通信协议。4.根据权利要求1所述的方法,其特征在于,所述若在预设时间内未监听到所述应答数据,则将所述串行接口作为一输入接口,用于接收所述外部设备的输入指令包括:若在预设时间内未监听到所述应答数据,则将所述串行接口处的电阻全部设置为上拉模式,作为一输入接口,用于接收所述外部设备的输入指令。5.根据权利要求1至4中任一项所述的方法,其特征在于,所述外部设备包括串口通讯设备或机械按键开关。6.一种串行接口的控制装置,...
【专利技术属性】
技术研发人员:龚飞,郭浩,
申请(专利权)人:深圳市晟瑞科技有限公司,
类型:发明
国别省市:广东,44
还没有人留言评论。发表了对其他浏览者有用的留言会获得科技券。