Print system kilomega network communication means, terminal and system
Technical field
The present invention relates to printing technique field more particularly to a kind of print system kilomega network communication means, terminal and system.
Background technique
With extensive use of the computer on figure or word processing, the application of printer is also become increasingly prevalent,
By printer, people can very easily will be on the text or images outputting to picture in computer.
In current print system, printing person assigns print command by computer, and printer is transmitted computer
Information printed.Common printer has ink-jet printer and laser printer, wherein ink-jet printer using spray head into
Row printing, and laser printer carries out static dump using laser beam and photosensitive drums.Ink-jet printer is cheap and wide because of its
It is general to be applied to Industrial Printing field.
When the terminal (such as PC machine) in Industrial printing systems and the data volume transmitted between print control board are bigger
When, print data amount is also very big, general to can no longer meet in such a way that USB carries out data communication to print control
Demand.So needing special kilomega network communication plan to solve big data quantity, the demand of high-speed transfer.
Summary of the invention
It is a primary object of the present invention to propose a kind of print system kilomega network communication means, terminal and system, it is intended to solve
The volume of transmitted data of certainly existing print system is small, the low technical problem of transmission rate.
To achieve the above object, one aspect of the present invention provides a kind of print system kilomega network communication means, and the method is answered
For in the print system including terminal and print control snap-gauge, which comprises
Establish the default communication protocol between the terminal and the print control snap-gauge;
The identical data frame of size is packaged by data are transmitted according to the default communication protocol;
The data frame transfer is given to print control snap-gauge by winpcap driving interface.
Further, the default communication protocol is based on User Datagram Protocol UDP, in which:
Network layer passes through the internet IP in IP agreement using interconnection agreement and Address Resolution Protocol ARP between IP network
Protocol address distinguishes different print control snap-gauges;
Link layer protocol is realized by 10M/100M/1000M mac controller, for that will transmit data according to Ethernet protocol
Frame decoding and encapsulation;
Physical layer protocol is realized by gigabit PHY;
Application layer protocol is custom protocol.
Further, the application layer protocol includes: protocol header, order, serial number, address, data length and data;
Wherein, the protocol header indicates address of devices, for distinguishing the frame that present frame is print control snap-gauge, or spray
The frame of sweep;
The mode of operation ordered for determining the print data and the control parameter;
The serial number indicates the serial number of data packet, for ensuring the integrality of data packet number;
The address includes print data address and print parameters address;
When write order, the data length indicates the byte length of write-in data, when read command, the data length
Indicate the byte length of reading data;
When write order, the data indicate that the data of destination address are written, and when read command, the data are filling
Data.
Further, the transmission data include print data and control parameter, described according to the default communication protocol
Transmission data, which are packaged into the identical data frame of size, includes:
Judge whether the sequence number counter in current data packet serial number and mainboard matches according to the serial number,
Corresponding operation is executed to the print data and control parameter according to the order, the corresponding operating includes:
Data writing operation reads data manipulation, write parameters operation, reads parameter manipulation, presses byte write operations;
Print data address and print parameters address are adjusted according to the address;
Print data and print parameters are handled according to the data length;
Corresponding destination address is written into the data that destination address is written.
Further, described to establish before the default communication protocol between the terminal and the print control snap-gauge, institute
State method further include:
Network interface card information is configured.
Further, described be configured to network interface card includes:
Network interface card information is obtained by the library WinPcap, it is ensured that opens the network interface card after network interface card information is normal;
By WinPcap lab setting network interface card buffer area, to store transmission data;
By WinPcap lab setting network interface card filtering rule, so that network interface card receives target data.
Further, described to include: to print control snap-gauge by the data frame transfer by winpcap driving interface
The network interface card buffer area is sent by data frame by the library WinPcap;
By kilomega network by the data receiver of the data frame transfer in the network interface card buffer area to print control snap-gauge.
Further, the method also includes:
Network card data frame is read by the library WinPcap;
The network card data frame is stored in the network interface card buffer area;
The data frame is parsed according to the default communication protocol between the terminal and the print control snap-gauge.
Another aspect of the present invention also provides a kind of print system kilomega network communication terminal, and the terminal includes:
Creation module, the default communication protocol for establishing between the terminal and the print control snap-gauge;
Package module, for being packaged into the identical data frame of size for data are transmitted according to the default communication protocol;
Transmission module, for giving the data frame transfer to print control snap-gauge by winpcap driving interface.
Another aspect of the present invention also provides a kind of print system gigabit network communication system, including above-described print system
Kilomega network communication terminal and print control snap-gauge.
A kind of print system kilomega network communication means, terminal and system provided by the invention, by customized terminal and
Communication transport protocols between print control board, in conjunction with the public free network access system under windows platform
The library winpcap is encapsulated into kilomega network communication interface, realizes the big data quantity of large-scale print control system, the need of high-speed transfer
It asks.
Detailed description of the invention
Fig. 1 is a kind of print system kilomega network communication means flow chart that the embodiment of the present invention one provides;
Fig. 2 is a kind of print system kilomega network communication means flow chart provided by Embodiment 2 of the present invention;
Fig. 3 is a kind of print system kilomega network communication terminal structural schematic diagram that the embodiment of the present invention three provides.
The embodiments will be further described with reference to the accompanying drawings for the realization, the function and the advantages of the object of the present invention.
Specific embodiment
It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, it is not intended to limit the present invention.
In subsequent description, it is only using the suffix for indicating such as " module ", " component " or " unit " of element
Be conducive to explanation of the invention, itself there is no a specific meaning.Therefore, " module ", " component " or " unit " can mix
Ground uses.
In the present invention, terminal can be implemented in a variety of manners.For example, terminal described in the present invention may include such as
The fixed terminals such as desktop computer, number TV, and such as mobile phone, tablet computer, laptop, palm PC, a number
Word assistant (Personal Digital Assistant, PDA), portable media player (Portable Media
Player, PMP), navigation terminal, wearable device, Intelligent bracelet, the mobile terminals such as pedometer.
The present invention provides a kind of print system kilomega network communication means, and the method is applied to include terminal and print control
In the print system of snap-gauge, which comprises
S1, default communication protocol between the terminal and the print control snap-gauge is established;
S2, the identical data frame of size is packaged into for data are transmitted according to the default communication protocol;
S3, the data frame transfer is given to print control snap-gauge by winpcap driving interface.
A kind of print system kilomega network communication means provided by the invention, passes through customized terminal and print control board
Between communication transport protocols, be encapsulated into conjunction with the public free library network access system winpcap under windows platform
Kilomega network communication interface realizes the big data quantity of large-scale print control system, the demand of high-speed transfer.
Detailed description of the preferred embodiments below.
Embodiment one
A kind of print system kilomega network communication means provided as shown in Figure 1 for the embodiment of the present invention one, the method are answered
For in the print system including terminal and print control snap-gauge, which comprises
S101, default communication protocol between the terminal and the print control snap-gauge is established;
In a kind of specific embodiment, the default communication protocol is based on User Datagram Protocol (User
Datagram Protocol, UDP), in which:
Network layer passes through the internet IP in IP agreement using interconnection agreement and arp address resolution protocol between IP network
Protocol address distinguishes different print control snap-gauges;Specifically, when there is muti-piece print control snap-gauge, it is necessary to pass through IP address
Identify different print control snap-gauges, it since parameter of the print control snap-gauge after having produced all is consistent, must after installation
It need determine spray head corresponding to every piece of print control snap-gauge, so in the present embodiment, by unique IP address come area
Not different print control snap-gauges.
Link layer protocol is realized by 10M/100M/1000M mac controller, for that will transmit data according to Ethernet protocol
(ethernet agreement) frame decoding and encapsulation;
Physical layer protocol is realized by gigabit PHY;
Application layer protocol is custom protocol.
In the present embodiment, terminal, if PC machine controls entire print system by gigabit networking, in the case where single mainboard
PC directly passes through cable with mainboard and connects, and in the case where muti-piece mainboard, PC and mainboard are connect on gigabit switch, passes through interchanger
It is communicated;Mainboard supports 10M/100M/1000M communication.PC needs that data, i.e. print data and control will be transmitted by network
Parameter is transferred to mainboard, and the correlated condition of print data and control parameter is read from mainboard.
In a kind of specific embodiment, as shown in table 1, the application layer protocol include: protocol header, order, serial number,
Address, data length and data;
1 application layer protocol data structure of table
Wherein, the protocol header indicates address of devices, for distinguishing the frame that present frame is print control snap-gauge, or spray
The frame of sweep;Wherein, the frame of print control snap-gauge is 8 ' h80, the frame for spraying sweep be respectively 8 ' h00,8 ' h01 ... 8 ' h0f, it is right
Answer 16 blocks of spray sweeps, the natural number of f 0,1,2 ... 16, in addition 8 ' h10 is spray sweep broadcast address.
The mode of operation ordered for determining the print data and the control parameter;Every BIT is defined as follows:
BIT7: read and write control bit, 1: writing, 0: reading.
BIT6:REV;
BIT5: write address is continuous, discontinuous control bit, and 1: it is discontinuous, 0: continuous.
BIT4: response control bit, 1: response, 0: not replying, read the data position and be necessary for 1.
BIT3-BIT0: channel selecting, 1: data channel, 2: parameter channel, other reservations.
Return command:
BIT6-BIT4: error code;0: order is correct.
The serial number indicates the serial number of data packet, for ensuring the integrality of data packet number;
The address includes print data address and print parameters address;
When write order, the data length indicates the byte length of write-in data, when read command, the data length
Indicate the byte length of reading data;
When write order, the data indicate that the data of destination address are written, and when read command, the data are filling
Data.
S102, the identical data frame of size is packaged into for data are transmitted according to the default communication protocol;
In the present embodiment, the transmission data include print data and control parameter, described according to the default communication protocols
Transmission data are packaged into the identical data frame of size by view
S1021, judge whether the sequence number counter in current data packet serial number and mainboard matches according to the serial number,
Specifically, often receiving a correct data packet, mainboard serial number checks that module will compare the serial number and mainboard
On sequence number counter whether match, mismatch and then write down the value of current sequence number to erroneous packets example table cache RAM, host computer is every
Secondary data can read the list after having passed, decision is to retransmit total data, or selectivity sends the number of corresponding serial number
According to packet, the number-of-packet that host computer continuously transmits every time is no more than 65536, it is necessary to master before sending 65536 data packets
Plate packet receiving error counter is detected, and can continue to send if inerrancy occurs, and needs first to send out again if an error has occurred
Send the data packet (being had to when retransmission data using ACK function, to confirm that data packet is correctly sent) of mistake, and flushing errors packet
Counter.Before transmission data packet every time, host computer is such as uncertain it needs to be determined that data packet serial number required for mainboard, can be with
Restart to calculate from 0 by first reading mainboard register or reset sequence number counter, serial number.
The part does not work when parameter reading and writing, it is proposed that all write parameters orders use acknowledgement command, when writing as received
Wrong responses or time-out, which do not receive response then, indicates transmission failure, decides whether to retransmit by host computer.Host computer is super
When wait and upper to distinguish answer signal and read data return, wherein answer signal do not need to carry out additional operation be can be fast
What speed returned, and read operation if it is carry out peripheral hardware or storage operation need the regular hour could returned data, it is corresponding
Waiting time should lengthen accordingly.
S1022, corresponding operation, the corresponding operating are executed to the print data and control parameter according to the order
Include: data writing operation, reads data manipulation, write parameters operation, reads parameter manipulation, by byte write operations;
In the present embodiment, specific operational order has: 0X81: writing data (unresponsive), OX91 (forces response);0X11:
Read data;0x82: write parameters (unresponsive);0x92: write parameters (force response);0xA2: being write by byte, need to specify Offsets ground
Location supports address discontinuous;0x12: parameter is read;When read operation, mainboard can will be read to be sent to mainboard in content, and response is suitable
In once reading mainboard register manipulation.
S1023, print data address and print parameters address are adjusted according to the address;
In the present embodiment, address 4 bytes in total, low byte is divided into print data address and print parameters address preceding,
4Byte data are each specified in print data address, and since address size is limited, the low address 2BIT is by FPGA polishing, and BIT0
It is only 0, that is, data manipulation needs 8BYTE alignment (memory bar data bit width is 64BIT);Argument address is also 4 words
Section, each address corresponds to 1Byte data, but the data bit width position 32BIT of system bus, different operations have centainly address
Requirement.When write parameters operate, it is divided into address of continuously writing and specify Offsets and writes;Continuously write: the initial address of specified write operation, it will
Data by address is sequentially written in corresponding address, and each write operation is as unit of 4 bytes, it is desirable that and 4 byte-aligned of address space is that is, low
2Bit is 0;The address that specifies Offsets write: specifying Offsets address for the data of each write-in, every time operation as unit of 1 byte, this
When, " address " is the base address of parameter, and low 8bit is invalid, and needs the address that specifies Offsets before each data.Read operation is only
Can continuously read, address is also required to 4 byte-aligneds, at " address " continuous read designated length byte number.
S1024, print data and print parameters are handled according to the data length.
Specifically, indicating the byte length that data are written, wherein length packet when the address that specifies Offsets is write when write operation
Containing offset address, if length is unsatisfactory for 4 byte integers times, the remaining data meeting less than 4 bytes in continuous write operation
It is dropped, the length that read data, the integral multiple that length is 4, extra will not read less than 4 bytes is indicated when read operation.It is long
Degree is up to 1460 bytes, and read-write is more than that the value will lead to mistake.
S1025, corresponding destination address is written into the data that destination address is written.
In the present embodiment, when receiving write order, the data that destination address is written are indicated.When receiving read operation
To fill data, it is not intended to justice.
Specifically, data come out only remaining user data from UDP module, position that mainboard is defined by application layer protocol is by phase
The command parameter answered is written corresponding register, and operation is to as in write-in RAM caching, further according to order by data and control command
It is converted to corresponding form writing commands queue FIFO, data FIFO is written in data.
For acknowledgement frame, a read register order write-in mission queue is automatically generated if order has response demand,
Acknowledgement frame is generated after the write operation is completed.
In the present embodiment, data being write, reading data channel, two channels of each channel divided data and order, each channel is used
FIFO is cached.
S103, the data frame transfer is given to print control snap-gauge by winpcap driving interface.
Specifically, this step includes:
S1031, the network interface card buffer area is sent for data frame by the library WinPcap;
S1032, the data of data frame transfer to print control snap-gauge in the network interface card buffer area are connect by kilomega network
Receiving end.
Embodiment two
It is illustrated in figure 2 a kind of flow chart of print system kilomega network communication means provided by Embodiment 2 of the present invention, it should
Communication described in method is two-way communication, and computer needs to transmit data by network, i.e. print data and control parameter passes
It is defeated arrive mainboard, and from mainboard read print data and control parameter correlated condition.Wherein, computer end and print control board end
There is gigabit ethernet card, the two is connected by kilomega network cable.Print controlling software is mounted on computer end, print control board
There is FPGA to handle data information in end.This method comprises:
S201, network interface card is configured.
Specifically, this step includes:
S2011, network interface card information is obtained by the library WinPcap, it is ensured that the network interface card is opened after network interface card information is normal;
S2012, pass through WinPcap lab setting network interface card buffer area, to store transmission data;
S2013, pass through WinPcap lab setting network interface card filtering rule, so that network interface card receives target data.
S202, the identical data frame of size is packaged into for data are transmitted according to default communication protocol;
Wherein, default communication protocol is the default communication protocol between the terminal and the print control snap-gauge;One
In kind specific embodiment, the default communication protocol is based on UDP, in which:
Network layer passes through the internet IP in IP agreement using interconnection agreement and arp address resolution protocol between IP network
Protocol address distinguishes different print control snap-gauges;Specifically, when there is muti-piece print control snap-gauge, it is necessary to pass through IP address
Identify different print control snap-gauges, it since parameter of the print control snap-gauge after having produced all is consistent, must after installation
It need determine spray head corresponding to every piece of print control snap-gauge, so in the present embodiment, by unique IP address come area
Not different print control snap-gauges.
Link layer protocol is realized by 10M/100M/1000M mac controller, for that will transmit data according to Ethernet protocol
(ethernet agreement) frame decoding and encapsulation;
Physical layer protocol is realized by gigabit PHY;
Application layer protocol is custom protocol.
Application layer custom protocol and according to default communication protocol by transmit data be packaged into the identical data frame of size
Mode has detailed narration in step S101 and S1021~S1025, and details are not described herein.
In specific implementation process, processed print data or control parameter are stored temporarily in caching first by this step
In;Data will be transmitted further according to default communication protocol and are packaged into the identical data frame of size, and pass through the library WinPca-p for data
Packet is sent to network interface card buffer area, last gigabit networking by network interface card cache in data packet be transmitted to print control board, printing control
Fabrication plate receiving terminal is handled data by FPGA.
S203, the data frame transfer is given to print control snap-gauge by winpcap driving interface.
Specifically, this step includes:
S2031, the network interface card buffer area is sent for data frame by the library WinPcap;
S2032, the data of data frame transfer to print control snap-gauge in the network interface card buffer area are connect by kilomega network
Receiving end.
S204, the data that print control snap-gauge returns are received by winpcap driving interface.
Specifically, this step includes:
S2041, network card data frame is read by the library WinPcap;
S2042, the network card data frame is stored in the network interface card buffer area;
S2043, the data frame is parsed according to the default communication protocol between the terminal and the print control snap-gauge.
Based on above-mentioned each embodiment of the method, the following each terminal embodiment of the present invention is proposed.
Embodiment three
A kind of print system kilomega network communication terminal 3, as shown in Figure 3, comprising:
Creation module 31, the default communication protocol for establishing between the terminal and the print control snap-gauge;
Package module 32, for being packaged into the identical data frame of size for data are transmitted according to the default communication protocol;
Transmission module 33, for giving the data frame transfer to print control snap-gauge by winpcap driving interface.
In a specific embodiment, the default communication protocol is based on User Datagram Protocol UDP, in which:
Network layer passes through the internet IP in IP agreement using interconnection agreement and Address Resolution Protocol ARP between IP network
Protocol address distinguishes different print control snap-gauges;
Link layer protocol is realized by 10M/100M/1000M mac controller, for that will transmit data according to Ethernet protocol
Frame decoding and encapsulation;
Physical layer protocol is realized by gigabit PHY;
Application layer protocol is custom protocol.
In a specific embodiment, the application layer protocol includes: that protocol header, order, serial number, address, data are long
Degree and data;
Wherein, the protocol header indicates address of devices, for distinguishing the frame that present frame is print control snap-gauge, or spray
The frame of sweep;
The mode of operation ordered for determining the print data and the control parameter;
The serial number indicates the serial number of data packet, for ensuring the integrality of data packet number;
The address includes print data address and print parameters address;
When write order, the data length indicates the byte length of write-in data, when read command, the data length
Indicate the byte length of reading data;
When write order, the data indicate that the data of destination address are written, and when read command, the data are filling
Data.
In a specific embodiment, the transmission data include print data and control parameter, described Encapsulation Moulds
Block 32 includes:
Judgment module, for judged according to the serial number sequence number counter in current data packet serial number and mainboard whether
Match,
Execution module, it is described for executing corresponding operation to the print data and control parameter according to the order
Corresponding operating includes: data writing operation, reads data manipulation, write parameters operation, reads parameter manipulation, by byte write operations;
Module is adjusted, for being adjusted according to the address to print data address and print parameters address;
Processing module, for being handled according to the data length print data and print parameters;
Writing module, for corresponding destination address to be written in the data that destination address is written.
In a specific embodiment, the print system kilomega network communication terminal 3 further include:
Setup module, for being configured to network interface card information.
In a specific embodiment, the setup module includes:
Module is obtained, for obtaining network interface card information by the library WinPcap, it is ensured that the network interface card is beaten after network interface card information is normal
It opens;
First setup module, for passing through WinPcap lab setting network interface card buffer area, to store transmission data;
Second setup module, for passing through WinPcap lab setting network interface card filtering rule, so that network interface card receives target data.
In a specific embodiment, the transmission module 33 includes:
Sending module, for sending the network interface card buffer area for data frame by the library WinPcap;
First transmission module, for passing through kilomega network for the data frame transfer in the network interface card buffer area to printer adapter
The data receiver of plate.
In a specific embodiment, the print system kilomega network communication terminal 3 further include:
Read module, for reading network card data frame by the library WinPcap;
Memory module, for the network card data frame to be stored in the network interface card buffer area;
Parsing module, for according to the default communication protocol parsing between the terminal and the print control snap-gauge
Data frame.
Example IV
The embodiment of the present invention four provides a kind of print system gigabit network communication system, including terminal and printer, wherein institute
Stating terminal is print system kilomega network communication terminal as shown in Figure 3.
A kind of print system kilomega network communication means, terminal and system provided by the invention, by customized terminal and
Communication transport protocols between print control board, in conjunction with the public free network access system under windows platform
The library winpcap is encapsulated into kilomega network communication interface, realizes the big data quantity of large-scale print control system, the need of high-speed transfer
It asks.
It should be noted that, in this document, the terms "include", "comprise" or its any other variant are intended to non-row
His property includes, so that the process, method, article or the terminal that include a series of elements not only include those elements, and
And further include other elements that are not explicitly listed, or further include for this process, method, article or terminal institute it is intrinsic
Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including being somebody's turn to do
There is also other identical elements in the process, method of element, article or terminal.
The serial number of the above embodiments of the invention is only for description, does not represent the advantages or disadvantages of the embodiments.
Through the above description of the embodiments, those skilled in the art can be understood that above-described embodiment side
Method can be realized by means of software and necessary general hardware platform, naturally it is also possible to by hardware, but in many cases
The former is more preferably embodiment.Based on this understanding, technical solution of the present invention substantially in other words does the prior art
The part contributed out can be embodied in the form of software products, which is stored in a storage medium
In (such as ROM/RAM, magnetic disk, CD), including some instructions are used so that a terminal (can be mobile phone, computer, service
Device, air conditioner or network equipment etc.) execute method described in each embodiment of the present invention.
The embodiment of the present invention is described with above attached drawing, but the invention is not limited to above-mentioned specific
Embodiment, the above mentioned embodiment is only schematical, rather than restrictive, those skilled in the art
Under the inspiration of the present invention, without breaking away from the scope protected by the purposes and claims of the present invention, it can also make very much
Form, all of these belong to the protection of the present invention.