CN111444129B - Method for transmitting MDB data and terminal equipment - Google Patents

Method for transmitting MDB data and terminal equipment Download PDF

Info

Publication number
CN111444129B
CN111444129B CN202010146576.4A CN202010146576A CN111444129B CN 111444129 B CN111444129 B CN 111444129B CN 202010146576 A CN202010146576 A CN 202010146576A CN 111444129 B CN111444129 B CN 111444129B
Authority
CN
China
Prior art keywords
data
mdb
serial port
bit value
calculating
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010146576.4A
Other languages
Chinese (zh)
Other versions
CN111444129A (en
Inventor
汪彦飞
谢利洪
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
PAX Computer Technology Shenzhen Co Ltd
Original Assignee
PAX Computer Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by PAX Computer Technology Shenzhen Co Ltd filed Critical PAX Computer Technology Shenzhen Co Ltd
Priority to CN202010146576.4A priority Critical patent/CN111444129B/en
Publication of CN111444129A publication Critical patent/CN111444129A/en
Application granted granted Critical
Publication of CN111444129B publication Critical patent/CN111444129B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4282Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/08Error detection or correction by redundancy in data representation, e.g. by using checking codes
    • G06F11/10Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • Information Transfer Systems (AREA)

Abstract

The invention is suitable for the technical field of data processing, and provides a method and a terminal device for MDB data transmission, wherein the method comprises the following steps: calculating to obtain a mode bit value of the MDB data according to the read data in the serial port controller; forming MDB data based on the mode bit value of the MDB data and the data, and sending the MDB data to an application program so that the application program generates MDB response data according to the MDB data; calculating to obtain a check bit value of the corresponding serial port data according to the MDB response data; and forming serial port data based on the check bit value of the serial port data and the MDB response data, and outputting the serial port data through a serial port controller. Compared with the prior art in which a mode of externally expanding chips is adopted, the invention does not increase a hardware structure and a peripheral circuit, thereby reducing extra workload and product maintenance difficulty, improving the MDB data transmission efficiency and being beneficial to meeting the strict time sequence requirement of MDB.

Description

Method for transmitting MDB data and terminal equipment
Technical Field
The invention belongs to the technical field of data processing, and particularly relates to a method for transmitting MDB data and terminal equipment.
Background
At present, the communication between the main controller and the peripheral equipment in the vending machine generally adopts an MDB protocol to realize MDB data transmission. The MDB is a short for MDB/ICP Protocol (Multi-Drop Bus/Internal Communication Protocol), and the Communication format specified in the MDB Protocol is to use a 9-bit universal serial port for MDB data transmission, where the 9-bit universal serial port includes a 1-bit mode bit and an 8-bit data bit. However, the main controller of the vending machine only supports 9-bit MDB data transmission, and if the POS terminal (peripheral) does not have the function of a 9-bit serial port device for MDB data transmission or the 9-bit serial port resource is limited, the communication between the main controller and the peripheral cannot be completed.
In order to solve the above problems, currently, the MDB data communication can be realized by providing an external expansion chip supporting a 9-bit serial port, that is, the main controller transmits 8-bit data to the external expansion chip, and the external expansion chip converts the 8-bit data into 9-bit data and then transmits the 9-bit data to the MDB link for communication with the external device.
However, the complexity of hardware circuit design is increased and the required space is increased due to the addition of the external expansion chip between the main controller and the peripheral; an application program for realizing data conversion and data synchronization with the main controller needs to be independently developed for the external expansion chip, so that extra work is added, and the product maintenance difficulty is increased; when MDB data communication is performed, data conversion causes a communication time to be extended, and transmission timing required by an MDB protocol may not be satisfied, resulting in unstable MDB data communication.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method for MDB data transmission and a terminal device, which are used to solve the problems of complicated hardware circuit design, difficult product maintenance and unstable MDB data communication caused by adding an external extended chip in the prior art.
In order to achieve the above object, a first aspect of the embodiments of the present invention provides a method for MDB data transmission, where an MDB driver is set in an MDB master control end or an MDB peripheral end, a device corresponding to the MDB driver is provided with a universal serial port, and the universal serial port is controlled by a serial port controller, where the method for MDB data transmission includes:
reading data from a serial port controller, and calculating a mode bit value of MDB data according to the read data;
forming MDB data based on the mode bit value of the MDB data and the data, and sending the MDB data to an application program so that the application program completes corresponding services according to the MDB data and generates MDB response data;
receiving the MDB response data, and calculating to obtain a check bit value of corresponding serial port data according to the MDB response data;
and forming the serial port data based on the check bit value of the serial port data and the MDB response data, and outputting the serial port data through the serial port controller.
As another embodiment of the present application, the calculating a mode bit value of MDB data according to the read data includes:
respectively calculating a first check code and a second check code according to the read data;
and calculating the mode bit value of the MDB data according to the first check code and the second check code.
As another embodiment of the present application, the data includes first serial port data, check error flag data, and current check mode data;
the calculating a first check code and a second check code respectively according to the read data includes:
calculating a first check code according to the first serial port data;
and calculating a second check code according to the check error marking data and the current check mode data.
As another embodiment of the present application, the calculating to obtain the check bit value of the corresponding serial port data according to the MDB response data includes:
determining a mode bit value of the MDB response data according to the MDB response data;
calculating a third check code according to the MDB response data;
and calculating to obtain a check bit value of the corresponding serial port data according to the mode bit value and the third check code.
As another embodiment of the present application, the determining a mode bit value of the MDB response data according to the MDB response data includes:
and performing AND operation on data obtained after the right shift operation of the MDB response data and preset data, and determining a mode bit value of the MDB response data.
As another embodiment of the present application, the method further includes:
and setting the time interval of data transmission of the serial port controller.
As another embodiment of the present application, before sending the MDB data to an application program and before outputting the serial port data through the serial port controller, the method further includes:
when the MDB data or the serial port data to be sent are sent, calculating the time difference between the current system time and the data sending completion time of the previous serial port controller;
determining a timing time according to the time difference and the time interval;
and when the timing time is up, sending the MDB data or the serial port data.
A second aspect of the embodiments of the present invention provides an apparatus for MDB data transmission, including:
the reading module is used for reading data from the serial port controller;
the calculation module is used for calculating the mode bit value of the MDB data according to the read data;
the processing module is used for forming MDB data based on the mode bit value of the MDB data and the data, and sending the MDB data to an application program so that the application program completes corresponding services according to the MDB data and generates MDB response data;
a receiving module, configured to receive the MDB response data;
the computing module is further used for computing a check bit value of the corresponding serial port data according to the MDB response data;
the processing module is further configured to form the serial port data based on the check bit value of the serial port data and the MDB response data, and output the serial port data through the serial port controller.
A third aspect of an embodiment of the present invention provides a terminal device, including: a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the steps of the method for MDB data transmission as described in any of the above embodiments when executing the computer program.
A fourth aspect of an embodiment of the present invention provides a computer-readable storage medium, including: the computer-readable storage medium stores a computer program, which when executed by a processor implements the steps of the method for MDB data transmission according to any of the above embodiments.
Compared with the prior art, the embodiment of the invention has the following beneficial effects: the invention adopts the MDB driving program to complete the transmission of the MDB data, and compared with the mode of adopting an external extended chip in the prior art, the invention does not increase a hardware structure and a peripheral circuit, thereby reducing extra workload and product maintenance difficulty, improving the MDB data transmission efficiency and being beneficial to meeting the strict time sequence requirement of the MDB.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
Fig. 1 is a schematic flow chart illustrating an implementation of a method for MDB data transmission according to an embodiment of the present invention;
FIG. 2 is a diagram illustrating a method for calculating a mode bit value of MDB data according to an embodiment of the present invention;
fig. 3 is a schematic diagram of a method for calculating a check bit value of corresponding serial port data according to an embodiment of the present invention;
FIG. 4 is an exemplary diagram of a design structure hierarchy block diagram provided by an embodiment of the present invention;
fig. 5 is a schematic diagram of a method and an apparatus for MDB data transmission according to an embodiment of the present invention;
fig. 6 is a schematic diagram of a method and an apparatus for MDB data transmission according to another embodiment of the present invention;
fig. 7 is a schematic diagram of a terminal device according to an embodiment of the present invention.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the invention. It will be apparent, however, to one skilled in the art that the present invention may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present invention with unnecessary detail.
In order to explain the technical means of the present invention, the following description will be given by way of specific examples.
An application scenario of the present application is introduced. Since the main controller of the vending machine in the prior art only supports 9-bit MDB data transmission, and the POS terminal is in a communication mode of 8-bit serial port data, in order to implement the MDB data transmission, an MDB driver is provided in the POS terminal in the present application. When the user finishes the transaction payment by adopting the POS terminal on the vending machine, the main control computer of the vending machine interacts with the MDB driving program in the POS terminal. That is, the main control computer of the vending machine sends the 9-bit MDB data to the MDB driver, the MDB driver identifies the serial data read from the serial controller, determines the mode bit of the MDB data, that is, converts the 8-bit serial port communication data received from the serial controller into the 9-bit MDB data by combining the verification mode set by the driver and the verification error flag of the serial controller, and sends the correct 9-bit MDB data to the application program. When the application program finishes the business logic to generate response data (9-bit MDB data), the response data is sent to the MDB driver program, the MDB driver program sets a check bit of the serial port controller according to the mode bit of the received response data, and writes the lower 8 bits of the response data into a data register of the serial port controller and sends the data register to a main control computer of the automatic vending machine to finish the sending of the MDB data, so that the 9-bit MDB data transmission is realized by adopting an 8-bit serial port communication mode.
In this application, the data format of the 9-bit MDB data is set as follows: "mode bit +8 bits of valid data". The data format of the serial port data is as follows: "start bit + data bit a (8 bits) + check bit B (1 bit) + stop bit". The use of an 8-bit serial port to receive 9-bit MDB data may result in erroneous data reception, and therefore, the method for MDB data transmission described below needs to be used to identify and then perform MDB data transmission.
Fig. 1 is a schematic diagram of an implementation flow of a method for MDB data transmission according to an embodiment of the present invention, where it is to be noted that an MDB driver is set in an MDB main control end or an MDB peripheral end, a universal serial port is set on a device corresponding to the MDB driver, the universal serial port is controlled by a serial port controller, and a method for MDB data transmission is described in detail below.
Step 101, reading data from a serial port controller, and calculating a mode bit value of the MDB data according to the read data.
Optionally, the data read from the serial port controller may include the first serial port data, the check error flag data, and the current check mode data.
When the MDB driver of the POS terminal receives 9-bit MDB data sent by a main controller in the vending machine, 8-bit first serial port data rxdata, verification error mark data prerr and current verification mode data proe of the controller are read from the serial port controller.
For the check error flag, it should be noted that, since the serial controller receives 9-bit MDB data in the 8-bit serial data format, two points are described: firstly, a check mode of 8-bit serial port data communication, such as odd check or even check, is set in the serial port controller, that is, the value of the check bit B is determined; second, the algorithm of the MDB driver sets the mode bit in the 9-bit MDB data to be stored in the check bit B, so that the value of the check bit B determined by the serial controller may be different from the value of the mode bit of the MDB data, which may generate a check error flag of the serial controller.
Optionally, when the MDB driver reads data from the serial port controller, only 8-bit valid data can be read, and therefore it is impossible to read data of the check bit B, and the value of the mode bit cannot be determined, and therefore the mode bit value of the MDB data needs to be determined according to the read data.
Optionally, as shown in fig. 2, the step may include the following steps:
step 201, respectively calculating a first check code and a second check code according to the read data.
Optionally, the calculating the first check code and the second check code in this step may include: calculating a first check code according to the first serial port data; and calculating a second check code according to the check error marking data and the current check mode data.
Optionally, the parity check code data _ parity of the even parity of the 8-bit first serial port data rxdata is calculated, and the calculated parity check code is used as the first parity check code. It should be noted that, an odd parity manner may also be adopted in calculating the parity code, but the calculation method needs to be reset, and in this embodiment, an even parity manner is exemplarily described.
Optionally, the check error flag data and the current check mode data are subjected to exclusive or calculation to obtain a second check code. Optionally, the second parity is obtained according to controller _ parity ^ prerr ^ proe, where controller _ parity represents the calculated second parity, and "^" represents the xor operation sign.
Step 202, calculating to obtain a mode bit value of the MDB data according to the first check code and the second check code.
Optionally, this step may include: and carrying out exclusive OR calculation on the first check code and the second check code to obtain a mode bit value of the MDB data.
Optionally, the mode bit value of the MDB data is obtained according to the mode _ bit value data _ parity ^ controller _ parity. Wherein the mode _ bit value represents a mode bit value of the MDB data.
The mode _ bit value obtained in step 101 may be 1 or 0, and if the mode _ bit value is 1, it indicates that the mode bit of the MDB data received from the serial port controller is 1; on the contrary, if the mode _ bit value is 0, it indicates that the MDB data mode bit received from the serial port controller is 0.
Step 102, forming MDB data based on the mode bit value of the MDB data and the data, and sending the MDB data to an application program, so that the application program completes corresponding services according to the MDB data, and generates MDB response data.
Optionally, after the mode bit value of the MDB data is determined, the adjustment may be performed according to the format of the 8-bit serial port data of the serial port controller, that is, the value of the check bit B in the serial port data is set to the mode bit value of the MDB data obtained through calculation, so that the MDB data is forwarded to the application program by using the correct 9-bit MDB data, so that the application program performs corresponding service processing according to the received MDB data, and the MDB generates response data.
And 103, receiving the MDB response data, and calculating to obtain a check bit value of the corresponding serial port data according to the MDB response data.
Optionally, after receiving the MDB response data sent by the application program, the MDB driver needs to forward the MDB response data to the main control terminal through the serial port controller, that is, a proper verification mode of the serial port controller needs to be set according to the MDB response data, so that a verification bit value in the verification mode is consistent with a mode bit value, and the serial port controller transmits correct serial port data when sending data.
Alternatively, as shown in fig. 3, the present step may include the following steps.
Step 301, determining a mode bit value of the MDB response data according to the MDB response data.
Optionally, the present step includes: and performing AND operation on data obtained after the right shift operation of the MDB response data and preset data, and determining a mode bit value of the MDB response data.
Namely, according to target _ parity ═ (data > >8) &1, the mode bit value of the MDB response data is determined. Wherein target _ parity denotes a mode bit value, data denotes MDB response data, "> >" denotes a right shift operation symbol, and "&" denotes an and operation symbol. Optionally, (data > >8) indicates that the acquired lower 8-bit data of the data is a valid data bit.
Step 302, calculating a third check code according to the MDB response data.
Optionally, the parity check code data _ parity of even parity is calculated according to the lower 8 bits of data.
Step 303, calculating to obtain a check bit value of the corresponding serial port data according to the mode bit value and the third check code.
Optionally, this step may include: and carrying out exclusive OR calculation on the mode bit value and the third check code, and calculating to obtain a check bit value of the corresponding serial port data.
Optionally, the check bit value of the corresponding serial port data is calculated according to the controller _ parity ═ data _ parity ^ target _ parity, where the controller _ parity represents the check bit value.
When the controller _ parity is 0, the verification mode of the serial port controller needing to be set is even verification; when the controller _ parity is 1, it indicates that the verification mode of the serial port controller to be set is odd verification.
And 104, forming the serial port data based on the check bit value of the serial port data and the MDB response data, and outputting the serial port data through the serial port controller.
Optionally, after the check bit value of the serial port controller is determined, writing the low 8-bit data of the data into a data register of the serial port controller to form serial port data transmission.
Optionally, the MDB driver needs to know the mode bit value of the MDB data when sending the MDB data to the application program, so that the application program needs to perform corresponding processing according to the difference of the mode bit. When receiving the MDB response data sent by the application program, the check bit needs to be recognized so as to be sent to the main control end through the serial port controller. In order to realize the correct transfer of the MDB data between the application program and the MDB driver, an MDB function library is arranged. When the application program calls the MDB function library to send data, each MDB response data transmitted to the MDB function library is 16-bit s, wherein the lower 8-bit s is a data value, and the 9 th bit is a mode bit of the MDB data; when receiving data, the single MDB data read by the application through the MDB function library is also 16 bits s, where the lower 8 bits s are the data value and the 9 th bit is the mode bit of the received MDB data.
As shown in the design structure level block diagram of fig. 4, the overall software structure level is divided into three layers, from bottom to top, an MDB driver, an MDB function library and an application. The MDB driver layer is responsible for data interaction of an MDB protocol layer, the MDB function library provides an MDB development related function interface for an application program, and the application program layer is responsible for specific MDB service logic processing.
In order to realize strong portability of the MDB driver and facilitate quick transplantation of the MDB driver in MCUs of different models, the MDB driver may be divided into a driver base layer and an equipment control device control layer.
The driver base layer provides logical abstraction of the driving function, and provides 8-bit universal serial port using MDB equipment for upper layer application programs, and the driver base layer does not directly control hardware equipment. When the application program needs to receive and transmit MDB data, the base layer of the driver program calls a function of the device control layer to indirectly complete an actual function according to the use condition of the application program.
The device control layer completes actual control of hardware according to a using method of a current Microcontroller Unit (MCU), and actual transmission of MDB data is achieved. The Device control layer has a perfect Device control logic, receives data from the universal serial port, completes the conversion from 8-bit serial port data to MDB data according to the actual check bit, converts the MDB response data transmitted by the application layer into 8-bit serial port data, and transmits the 8-bit serial port data to a host Controller (VMC) of the Vending Machine to realize the MDB communication.
After the device control layer needs to complete the operation corresponding to the method for MDB data transmission described in any of the above embodiments, the following operations need to be completed: firstly, according to an MCU data manual, initializing a serial port controller according to the use requirement of an 8-bit universal serial port, setting the data length to be 8 bits, setting the check mode of the serial port controller to be odd check, stopping the bit length to be 1 bit, and setting the communication baud rate to be 9600 bps. Second, the MDB mode setting is completed according to the application program requirement, and it should be noted that the present application can be applied to the MDB main control end and the peripheral end at the same time, so that the application program is required to set the required working mode. In the MDB peripheral mode, the support application program sets the MDB address of the slave device, and can support the setting of multiple addresses to meet the special usage scene of the MDB slave device.
Optionally, the device control layer supports the application program to set a data transmission interval, and when data is transmitted to the MDB link, the data transmission speed is adjusted according to the data interval time set by the user, so as to adapt to VMCs with different processing capabilities.
Optionally, in the MDB protocol, the baud rate for transmitting the MDB data is set according to the MDB protocol. In general, the parameter determining the serial data transmission speed is the baud rate, and the higher the baud rate is, the higher the serial data transmission speed is. In a normal use scene, after the serial port baud rate is set, when data is sent, the serial port controller transmits high and low level information to the outside according to the set baud rate parameters to finish data transmission. After the transmission of 1 unit data is completed, the serial port controller can immediately take out the next data, and data transmission is carried out according to the same mode, so that the continuous transmission of the data is realized.
In this embodiment, due to the difference in data processing capability of the processors of different vending machines, the application program often fails to take new data sent by the serial controller in time during data processing, which causes overflow of serial data, resulting in data loss. In order to solve such a problem, it is a common practice to use a hardware flow control signal, and a receiving end controls a data transmission speed of a transmitting end by using the hardware flow control signal. However, in the MDB protocol, it is not specified that both parties participating in MDB communication use hardware flow control to solve the problem of data loss caused by differences in data processing capability, and most of the devices participating in MDB communication do not have hardware flow control lines, so that the problem of data loss caused by insufficient data processing capability cannot be solved through hardware flow control signal processing.
In this embodiment, the divece control layer support application program sets a data transmission interval according to the data processing capability of the specific device on the MDB link. Optionally, when the serial port controller is used for sending data, the time interval of sending the data of the serial port controller may be set.
Optionally, before the outputting the serial port data through the serial port controller, the method may further include:
when the serial port data are to be sent, calculating the time difference between the current system time and the last time when the serial port controller sends the data; determining timing time according to the time difference and the time interval, namely calculating a time difference value between the time interval and the time difference, and determining the time difference value as the timing time; and when the timing time is up, the serial port data is sent, so that the receiving end is ensured not to have data loss caused by mass data inrush in the data processing stage, and the adaptability to MDB equipment with different data processing capabilities is improved. In this embodiment, the serial controller sends data in an interrupt mode to reduce occupation of MCU resources as much as possible and fully exert the performance of the MCU.
According to the method for transmitting the MDB data, the mode bit value of the MDB data is obtained through calculation according to the data read from the serial port controller by adding the MDB driving program; forming MDB data based on the mode bit value of the MDB data and the data, and sending the MDB data to an application program so that the application program completes corresponding services according to the MDB data and generates MDB response data; calculating to obtain a check bit value of the corresponding serial port data according to the received MDB response data; and forming serial port data based on the check bit value of the serial port data and the MDB response data, and outputting the serial port data through a serial port controller. In the embodiment, the MDB driver is adopted to complete the transmission of the MDB data, and compared with the mode of adopting an external extended chip in the prior art, a hardware structure and a peripheral circuit are not added, so that the extra workload and the product maintenance difficulty are reduced, the MDB data transmission efficiency is improved, and the strict time sequence requirement of the MDB is favorably met.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
Fig. 5 illustrates an exemplary diagram of an apparatus for MDB data transmission according to an embodiment of the present invention, which corresponds to the method for MDB data transmission described in the above embodiments. As shown in fig. 5, the apparatus may include: a reading module 501, a calculating module 502, a processing module 503 and a receiving module 504.
A reading module 501, configured to read data from a serial port controller;
a calculating module 502, configured to calculate a mode bit value of the MDB data according to the read data;
a processing module 503, configured to form MDB data based on the mode bit value of the MDB data and the data, and send the MDB data to an application program, so that the application program completes a corresponding service according to the MDB data, and generates MDB response data;
a receiving module 504, configured to receive the MDB response data;
the calculating module 502 is further configured to calculate a check bit value of the corresponding serial port data according to the MDB response data;
the processing module 503 is further configured to form the serial port data based on the check bit value of the serial port data and the MDB response data, and output the serial port data through the serial port controller.
Optionally, when the calculating module 502 calculates the mode bit value of the MDB data according to the read data, it may be configured to:
respectively calculating a first check code and a second check code according to the read data;
and calculating the mode bit value of the MDB data according to the first check code and the second check code.
Optionally, the data includes first serial port data, check error flag data, and current check mode data.
Optionally, when the calculating module 502 calculates the first check code and the second check code according to the read data, it may be configured to:
calculating a first check code according to the first serial port data;
and calculating a second check code according to the check error marking data and the current check mode data.
Optionally, when the calculating module 502 calculates the second check code according to the check error flag data and the current check mode data, it may be configured to:
performing exclusive-or calculation on the check error marking data and the current check mode data to obtain a second check code;
when the calculation module 502 calculates the mode bit value of the MDB data according to the first check code and the second check code, it may be configured to:
and carrying out exclusive OR calculation on the first check code and the second check code to obtain a mode bit value of the MDB data.
Optionally, when the calculating module 502 calculates the check bit value of the corresponding serial port data according to the MDB response data, it may be configured to:
determining a mode bit value of the MDB response data according to the MDB response data;
calculating a third check code according to the MDB response data;
and calculating to obtain a check bit value of the corresponding serial port data according to the mode bit value and the third check code.
Optionally, when the calculating module 502 determines the mode bit value of the MDB response data according to the MDB response data, it may be configured to:
and performing AND operation on data obtained after the right shift operation of the MDB response data and preset data, and determining a mode bit value of the MDB response data.
Optionally, the calculating the check bit value of the corresponding serial port data according to the mode bit value and the third check code includes:
and carrying out exclusive OR calculation on the mode bit value and the third check code, and calculating to obtain a check bit value of the corresponding serial port data.
Optionally, as shown in fig. 6, the MDB data transmission apparatus further includes a setting module 505:
the setting module 505 is configured to set a time interval for data transmission of the serial port controller.
Before the processing module 503 outputs the serial port data through the serial port controller, the processing module 503 is further configured to:
when the serial port data are to be sent, calculating the time difference between the current system time and the last time when the serial port controller sends the data;
determining a timing time according to the time difference and the time interval; calculating the time difference value between the time interval and the time difference, and determining the time difference value as the timing time;
and when the timing time is up, the serial port data is sent.
According to the device for transmitting the MDB data, the MDB driver is added, the data are read from the serial port controller, and the mode bit value of the MDB data is calculated by the calculating module; the processing module sends the MDB data to the application program so that the application program completes corresponding services according to the MDB data and generates MDB response data; according to the received MDB response data, the calculation module calculates to obtain a check bit value of the corresponding serial port data; the processing module forms serial port data based on the check bit value of the serial port data and the MDB response data, and outputs the serial port data through the serial port controller. In the embodiment, the MDB driver is adopted to complete the transmission of the MDB data, and compared with the mode of adopting an external extended chip in the prior art, a hardware structure and a peripheral circuit are not added, so that the extra workload and the product maintenance difficulty are reduced, the MDB data transmission efficiency is improved, and the strict time sequence requirement of the MDB is favorably met.
Fig. 7 is a schematic diagram of a terminal device according to an embodiment of the present invention. As shown in fig. 7, the terminal device 700 of this embodiment includes: a processor 701, a memory 702, and a computer program 703, such as a program for MDB data transfer, stored in said memory 702 and executable on said processor 701. When the processor 701 executes the computer program 703, steps in the method embodiment of the MDB data transmission described above, such as steps 101 to 104 shown in fig. 1, or steps 201 to 202 shown in fig. 2, or steps 301 to 303 shown in fig. 3, are implemented, and when the processor 701 executes the computer program 703, functions of modules in each device embodiment described above, such as functions of modules shown in fig. 5 or fig. 6, are implemented.
Illustratively, the computer program 703 may be partitioned into one or more program modules, which are stored in the memory 702 and executed by the processor 701 to implement the present invention. The one or more program modules may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution process of the computer program 703 in the MDB data transmission apparatus or terminal device 700. For example, the computer program 703 may be divided into a reading module 501, a calculating module 502, a processing module 503 and a receiving module 504, or the computer program 703 may be divided into the reading module 501, the calculating module 502, the processing module 503, the receiving module 504 and a setting module 505, and specific functions of the modules are shown in fig. 5 or fig. 6, which are not described in detail herein.
The terminal device 700 may be a desktop computer, a notebook, a palm computer, a cloud server, or other computing devices. The terminal device may include, but is not limited to, a processor 701, a memory 702. Those skilled in the art will appreciate that fig. 7 is merely an example of a terminal device 700 and does not constitute a limitation of terminal device 700 and may include more or fewer components than shown, or some components may be combined, or different components, e.g., the terminal device may also include input-output devices, network access devices, buses, etc.
The Processor 701 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The storage 702 may be an internal storage unit of the terminal device 700, such as a hard disk or a memory of the terminal device 700. The memory 702 may also be an external storage device of the terminal device 700, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like provided on the terminal device 700. Further, the memory 702 may also include both an internal storage unit and an external storage device of the terminal device 700. The memory 702 is used for storing the computer programs and other programs and data required by the terminal device 700. The memory 702 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus/terminal device and method may be implemented in other ways. For example, the above-described embodiments of the apparatus/terminal device are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented. . Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.

Claims (8)

1. A method for transmitting MDB data is characterized in that an MDB driver is arranged in an MDB main control end or an MDB peripheral end, a universal serial port is arranged on equipment corresponding to the MDB driver, the universal serial port is controlled by a serial port controller, and the method for transmitting the MDB data comprises the following steps:
reading data from a serial port controller, and calculating a mode bit value of MDB data according to the read data, wherein the mode bit value comprises the following steps: respectively calculating a first check code and a second check code according to the read data; calculating a mode bit value of the MDB data according to the first check code and the second check code;
forming MDB data based on the mode bit value of the MDB data and the data, and sending the MDB data to an application program so that the application program completes corresponding services according to the MDB data and generates MDB response data;
receiving the MDB response data, and calculating to obtain a check bit value of the corresponding serial port data according to the MDB response data, wherein the check bit value comprises the following steps: determining a mode bit value of the MDB response data according to the MDB response data; calculating a third check code according to the MDB response data; calculating to obtain a check bit value of the corresponding serial port data according to the mode bit value and the third check code;
and forming the serial port data based on the check bit value of the serial port data and the MDB response data, and outputting the serial port data through the serial port controller.
2. The method of MDB data transmission according to claim 1, wherein the data includes first serial port data, check error flag data, and current check pattern data;
the calculating a first check code and a second check code respectively according to the read data includes:
calculating a first check code according to the first serial port data;
and calculating a second check code according to the check error marking data and the current check mode data.
3. The method of MDB data transmission according to claim 1, wherein the determining the mode bit value of the MDB response data according to the MDB response data includes:
and performing AND operation on data obtained after the right shift operation of the MDB response data and preset data, and determining a mode bit value of the MDB response data.
4. The method for MDB data transmission according to any of claims 1 to 3, further comprising:
and setting the time interval of data transmission of the serial port controller.
5. The method for MDB data transmission according to claim 4, wherein before the outputting the serial port data through the serial port controller, further comprising:
when the serial port data are to be sent, calculating the time difference between the current system time and the last time when the serial port controller sends the data;
determining a timing time according to the time difference and the time interval;
and when the timing time is up, the serial port data is sent.
6. An apparatus for MDB data transmission, comprising:
the reading module is used for reading data from the serial port controller;
the calculation module is used for calculating the mode bit value of the MDB data according to the read data, and comprises the following steps: respectively calculating a first check code and a second check code according to the read data; calculating a mode bit value of the MDB data according to the first check code and the second check code;
the processing module is used for forming MDB data based on the mode bit value of the MDB data and the data, and sending the MDB data to an application program so that the application program completes corresponding services according to the MDB data and generates MDB response data;
a receiving module, configured to receive the MDB response data;
the calculation module is further configured to calculate a check bit value of the corresponding serial port data according to the MDB response data, and includes: determining a mode bit value of the MDB response data according to the MDB response data; calculating a third check code according to the MDB response data; calculating to obtain a check bit value of the corresponding serial port data according to the mode bit value and the third check code;
the processing module is further configured to form the serial port data based on the check bit value of the serial port data and the MDB response data, and output the serial port data through the serial port controller.
7. A terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the method according to any of claims 1 to 5 when executing the computer program.
8. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 5.
CN202010146576.4A 2020-03-05 2020-03-05 Method for transmitting MDB data and terminal equipment Active CN111444129B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010146576.4A CN111444129B (en) 2020-03-05 2020-03-05 Method for transmitting MDB data and terminal equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010146576.4A CN111444129B (en) 2020-03-05 2020-03-05 Method for transmitting MDB data and terminal equipment

Publications (2)

Publication Number Publication Date
CN111444129A CN111444129A (en) 2020-07-24
CN111444129B true CN111444129B (en) 2021-10-29

Family

ID=71627257

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010146576.4A Active CN111444129B (en) 2020-03-05 2020-03-05 Method for transmitting MDB data and terminal equipment

Country Status (1)

Country Link
CN (1) CN111444129B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114326526B (en) * 2021-12-31 2023-07-07 福建新大陆支付技术有限公司 Vending machine, instruction parsing method, storage medium, and slave device thereof

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7076329B1 (en) * 2002-04-12 2006-07-11 Usa Technologies, Inc. Cashless vending transaction management by a vend assist mode of operation
CN109801436A (en) * 2019-01-24 2019-05-24 昆山毅普腾自动化技术有限公司 Automatic vending machine is paid in cash protocol conversion system
CN110762738A (en) * 2019-11-08 2020-02-07 宁波奥克斯电气股份有限公司 Multi-split protocol conversion control method, device and system and air conditioning system
CN110855696A (en) * 2019-11-19 2020-02-28 广州乐摇摇信息科技有限公司 Protocol switching equipment suitable for MDB/ICP bus tandem connection payment module

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN202159385U (en) * 2011-06-05 2012-03-07 贝克曼集团有限公司 Commodity bar code management system for vending machine

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7076329B1 (en) * 2002-04-12 2006-07-11 Usa Technologies, Inc. Cashless vending transaction management by a vend assist mode of operation
CN109801436A (en) * 2019-01-24 2019-05-24 昆山毅普腾自动化技术有限公司 Automatic vending machine is paid in cash protocol conversion system
CN110762738A (en) * 2019-11-08 2020-02-07 宁波奥克斯电气股份有限公司 Multi-split protocol conversion control method, device and system and air conditioning system
CN110855696A (en) * 2019-11-19 2020-02-28 广州乐摇摇信息科技有限公司 Protocol switching equipment suitable for MDB/ICP bus tandem connection payment module

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
一种新型自动售货机控制***研发;张建龙;《中国优秀硕士学位论文全文数据库(电子期刊)工程科技II辑》;20111231;C029-150 *

Also Published As

Publication number Publication date
CN111444129A (en) 2020-07-24

Similar Documents

Publication Publication Date Title
US8812758B2 (en) Mechanism to flexibly support multiple device numbers on point-to-point interconnect upstream ports
CN110750341B (en) Task scheduling method, device, system, terminal equipment and storage medium
CN109902053A (en) A kind of SPI communication method, terminal device and storage medium based on dual controller
US10831693B1 (en) Multicast master
US11138106B1 (en) Target port with distributed transactions
CN110399324A (en) It interrupts converter and interrupts conversion method
CN112162706A (en) Hard disk management method, device, equipment and machine readable storage medium
CN111026697A (en) Inter-core communication method, inter-core communication system, electronic device and electronic equipment
TW202121879A (en) System, apparatus and method for communicating telemetry information via virtual bus encodings
CN111444129B (en) Method for transmitting MDB data and terminal equipment
CN106126465A (en) A kind of data transmission method and device
CN115632976A (en) PCIE transaction layer message generation method, device and storage medium
CN109240979A (en) Data processing chip and LED display system
CN112422485A (en) Communication method and device of transmission control protocol
CN105068962A (en) I2C controller access method and I2C controller access system
CN115994115A (en) Chip control method, chip set and electronic equipment
CN103973581A (en) Method, device and system for processing message data
CN111371799B (en) Method, device and equipment for controlling data receiving and transmitting of MCTP (Multi-channel media Port) controller
CN106940684B (en) Method and device for writing data according to bits
CN110659143B (en) Communication method and device between containers and electronic equipment
CN114637574A (en) Data processing method, device and system based on paravirtualization equipment
CN108804362A (en) Serial ports bulk data transmission method, device and storage medium
CN116226021B (en) Data receiving and transmitting method and device and graphics processor
CN117873672A (en) Interrupt processing system, interrupt processing component, interrupt processing device, interrupt processing method, interrupt processing apparatus, and storage medium
CN113157610B (en) Data storage method and device, storage medium and electronic device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant