Background technology:
Embedded device is primarily of flush bonding processor, associated support hardware and embedded software equipment composition, and it is " device " that can work independently that integrate software and hardware.Flush bonding processor is primarily of a single-chip microcomputer or microcontroller composition.Associated support hardware comprises the fetch equipment etc. of display card, storage medium, communication apparatus, IC-card or credit card.Embedded device is different from general computer disposal equipment, and it does not possess jumbo storage medium as hard disk, and mostly uses flash memory as storage medium.Embedded software comprises hardware-related bottom software, operating equipment, graphical interfaces, communications protocol, database equipment, standardization browser and application software etc.
Tradition embedded device considers the problem of cost and power consumption, and under normal conditions, data transmission adopts serial line interface to carry out.Serial line interface refers to that data one ground order transmits, and is characterized in that communication line is simple, as long as a pair transmission line just can realize two-way communication, such as, can directly utilize telephone wire as transmission line, thus greatly reduce cost, be specially adapted to telecommunication, but transfer rate is slower.Article one, each bit data of information is called serial communication by the communication modes transmitted in order by turn.The feature of serial communication is: the transmission of data bit, and step-by-step order is carried out, and minimum need transmission line can complete; Cost is low but transfer rate is slow; The distance of serial communication can from several meters to a few km.
At present, smart machine externally carries out data transmission and usually uses WIFI, bluetooth or NFC etc., and such as, emerging panel computer generally wirelessly communicates with the equipment of periphery.Although some smart machine of the prior art is with I/O interface, directly cannot communicate with the serial line interface of traditional embedded device.Therefore, the develop rapidly of making rapid progress along with smart machine, the embedded device that smart machine and traditional employing serial line interface carry out communicating cannot realize direct data and transmit.
Summary of the invention:
Technical matters solved by the invention: the embedded device carrying out communicating with the smart machine of common I/O interface and traditional employing serial line interface in prior art cannot realize direct data and transmit.
The invention provides following technical scheme: a kind of smart machine and embedded device carry out the equipment of data transmission, comprise smart machine, embedded device, data line, described smart machine is provided with common I/O interface, described embedded device is provided with serial line interface, described data line one end connects common I/O interface, the described data line other end connects serial line interface, has serial communication protocol between described smart machine and embedded device.
The present invention adopts the common I/O interface of smart machine, it can be Parallel I/O interface, be connected with traditional embedded device by data line, and define the correctness that a set of Data Transport Protocol form ensures data transmission, and then achieve in prior art and carry out carrying out direct data transmission between the embedded device that communicates with the smart machine of common I/O interface and traditional employing serial line interface.
As a further improvement on the present invention, described smart machine is panel computer.Part panel computer of the prior art has interfaces for external devices, and such as, the panel computer of Android brand, has the USB interface of external equipment; The panel computer of apple brand has special purpose interface; Only a few panel computer has HDMI.The interface of above-mentioned all kinds of panel computer by being connected with traditional embedded device with its data line adapted, and ensures by serial communication protocol the correctness that between panel computer and embedded device, data are transmitted.
As a further improvement on the present invention, described data line is that serial line interface turns common I/O interface data wire.As preferably, described data line is that serial line interface turns USB interface data line.Smart machine of the prior art, comprises panel computer, and the I/O interface on it generally includes USB interface, therefore the preferred serial line interface of data line in the present invention turns USB interface data line.
Embodiment:
As shown in Figure 1, a kind of smart machine and embedded device carry out the equipment of data transmission, comprise smart machine 10 (preferred panel computer), embedded device 20, serial line interface turn USB interface data line 30.
Described smart machine 10 is provided with usb 1 00, and described embedded device 20 is provided with serial line interface 200.
Described serial line interface turns the USB interface that USB interface data line 30 one end connects smart machine 10, and the other end that described serial line interface turns USB interface data line 30 connects serial line interface 200.
Between described smart machine 10 and embedded device 20, there is serial communication protocol.
The command format of described serial communication protocol is as following table:
The status format of described serial communication protocol is as following table:
Order and the parameter of described serial communication protocol are as follows:
Smart machine controls equipment and sends startup command: allow embedded device control panel start data transmission.
Command word: 0x81
Parameter: 1-button 1 (Hard); 2-button 2 (Middle); 3-button 3 (Soft)
Smart machine controls equipment and sends query State order: whether inquiry embedded device control panel receives related command or current state.
Command word: 0x82
Parameter: 1-order, 2-current operating state
After smart machine controls equipment transmission startup command, embedded device control panel sends working condition order:
Command word: 0x01
Parameter: 0-embedded device stirs and terminates; 1-sensor 1 is abnormal; 2-sensor 2 is abnormal;
Embedded device control panel sends query State order: inquiry smart machine controls equipment and whether receives related command:
Command word: 0x02
Parameter: 1-order
The status number of described serial communication protocol is as follows:
0-successfully receive orders
1-crc is not right, and data transmission has problem.
2-command word is illegal, and data transmission is correct.
3-do not need the order responded not receive any order bag data
4-the state that returns of embedded device control panel just at work
The host-host protocol particular content of described serial communication protocol is as follows:
The reliability that data are transmitted and integrality is guaranteed by 2 terrace works (order-state).After main frame sends order, from machine return state, if status data is invalid or in 1 second, countless certificate returns, main frame can pass through to send query State order, in secondary acquisition state.
Such as, smart machine controls equipment and sends startup command:
Packet is: 0x5A, 0x81,0x2,0xDD.
If embedded device control panel return state packet: 0xA5,0x0,0xA5.This shows that embedded device control panel successfully receives this order.
If embedded device control panel return state packet: 0xA5,0x01,0xA6.If the return state of order bag is not 0, smart machine controls equipment to be needed to resend this order.Can learn abnormal cause according to status number, if state is 0x1, this shows that the data that embedded device control panel receives are not right.
If countless certificate returns in 1 second, or the state data packets CRC returned is not right, and smart machine controls equipment and sends querying command: 0x5A, 0x82,0x1,0xDD.
Main frame attempts acquisition state 5 times, if do not have data to return, thinks from machine and quits work; If status data is not right, think transmission abnormality.
Such as, after smart machine controls equipment transmission startup command, embedded device control panel sends working condition order:
Packet is: exception reported by 0x5A, 0x01,0x2,0x5D sensor 2.
If smart machine controls equipment return state packet: 0xA5,0x80,0x25.This shows that smart machine controls to equip successfully to receive this order.
Above content is only better embodiment of the present invention, and for those of ordinary skill in the art, according to thought of the present invention, all will change in specific embodiments and applications, this description should not be construed as limitation of the present invention.