CN103984665B - Serial communication device and method based on LabVIEW - Google Patents

Serial communication device and method based on LabVIEW Download PDF

Info

Publication number
CN103984665B
CN103984665B CN201410246988.XA CN201410246988A CN103984665B CN 103984665 B CN103984665 B CN 103984665B CN 201410246988 A CN201410246988 A CN 201410246988A CN 103984665 B CN103984665 B CN 103984665B
Authority
CN
China
Prior art keywords
data
frame
event
queue
state
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
CN201410246988.XA
Other languages
Chinese (zh)
Other versions
CN103984665A (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.)
Harbin Institute of Technology Institute of artificial intelligence Co.,Ltd.
Original Assignee
Harbin Institute of Technology
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 Harbin Institute of Technology filed Critical Harbin Institute of Technology
Priority to CN201410246988.XA priority Critical patent/CN103984665B/en
Publication of CN103984665A publication Critical patent/CN103984665A/en
Application granted granted Critical
Publication of CN103984665B publication Critical patent/CN103984665B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Communication Control (AREA)

Abstract

Serial communication device and method based on LabVIEW, belongs to serial port communication technology field.The present invention is to solve the problems, such as that the existing serial communication based on LabVIEW programmings has loss of data and parsing data frame program is lengthy and jumbled time-consuming more.Device includes UI events generation module, UI event processing modules, data is activation and receiver module, data resolution module and data disaply moudle;Four layers of producer consumer framework are formd in method and each modular concurrent is performed, data analyzing step is parsed according to parsing Frame Protocol using the data that the method for analysis state machine is received to serial ports and obtains complete parsing data frame, the integrality of communication data transfer is ensure that, program simple and clear, execution speed are fast and stable.The present invention is for the serial communication between host computer and slave computer.

Description

Serial communication device and method based on LabVIEW
Technical field
Serial communication device and method the present invention relates to be based on LabVIEW, belongs to serial port communication technology field.
Background technology
Serial ports is a kind of very general equipment communication agreement on computer, is conventional computer and external series equipment Between data transmission channel, the composition that virtual instrument system is current virtual instrument is constituted by serial bus and PC computers One of mode, with interface it is simple, it is easy to use the characteristics of.
In virtual instrument field, the LabVIEW of NI companies is more next as a programming language for aiming at test measuring and design More noticeable, it overcomes, and the tradition high level language program code such as VC, VB, C#, Java is tediously long, inconvenient carry out functions expanding etc. Shortcoming, with ease in use, intuitively graphic programming mode, its human-computer interaction interface is friendly, data visualization analysis, equipment The advantages of control ability is strong so that have great advantage in terms of data acquisition and instrument controlling, be more and more used for serial ports The communications field.
But, in the prior art, the serial communication based on LabVIEW programmings occurs that data receiver is not complete or is The problems such as empty, parsing data frame program is lengthy and jumbled time-consuming more, this has a strong impact on the communication quality of data.
The content of the invention
There is loss of data and parsing number the invention aims to solve the existing serial communication based on LabVIEW programmings Many problems are taken according to frame program is lengthy and jumbled, there is provided a kind of serial communication device and method based on LabVIEW.
Serial communication device based on LabVIEW of the present invention, the communicator is realized and bottom as host computer The communication of machine, it includes:
Action for perceiving human-computer interaction interface control, produce event and as the producer will produce event with character String form sends into the UI event generation modules of event message queue;
For receiving the character string in event message queue as consumer, and the corresponding event representated by character string is entered Row framing produces data frame, is re-used as the UI event processing modules of the data frame feeding instruction queue that the producer will produce;
Data frame for receiving instruction queue as consumer, the data frame serial ports is sent to slave computer;Connect simultaneously The serial data of slave computer transmission is received, and the data is activation of data receiver queue is sent into as the serial data that the producer will receive With receiver module;
For receiving the data in data receiver queue as consumer and using analysis state machine to data receiving queue In data parsed, and as the producer will parse obtain data feeding parsing frame queue data resolution module;
For receiving the data in parsing frame queue and the data disaply moudle for being shown as the producer.
The UI events generation module is specifically included:
Action for perceiving human-computer interaction interface control, produces event, and the event is identified by being worth change Application affairs structure function;
For using the action of each control as an event branch, by each corresponding event command of event branch with word The element that symbol string form is stored in event message queue is joined the team array function.
The UI event processing modules are specifically included:
Element dequeue function for obtaining event message queue;
For event branch is corresponding with conditional branching, and framing is carried out according to protocol frame requirement, after CRC16 is verified As data frame to be sent, the element enqueue of instruction queue will be sent into after data frame to be sent and command string binding Function.
The data is activation is specifically included with receiver module:
For carry out VISA serial ports parameter, baud rate parameter, data bit parameter, stop position parameter, check bit parameter and The initial configuration of Row control parameter simultaneously disables respective attributes node in serial ports transceiving data to prevent the configuration change Serial ports configuration module;
For obtaining the data frame of instruction queue and the command string of binding by element dequeue function, by command word Symbol string judges branch for construction of condition, and data frame is write into serial ports by VISA sends to the serial ports sending module of slave computer;
Serial data for reading slave computer by VISA, and the slave computer data that will be read send into data receiver queue Serial ports receiver module;
Serial ports is closed for closing function by VISA, to recover the string of during initial configuration disabled attribute node Mouth closedown module.
The data resolution module is specifically included:
Element dequeue function for obtaining the data in data receiver queue;
For the analysis state machine parsed to the data in data receiving queue;
Sent into command string binding cluster after for the data that the parsing of analysis state machine is obtained to be converted into character string Parse the function of frame queue;
The data disaply moudle is specifically included:
Element dequeue function for obtaining the data in parsing frame queue;
For carrying out releasing binding to the data in parsing frame queue, command character is series-connected to construction of condition function Branch selector, after data character string is converted into byte arrays, the function for being shown.
A kind of serial port communication method based on LabVIEW, the communication means is used to realize that host computer is logical with slave computer Letter, it includes:
Action for perceiving human-computer interaction interface control, produce event and as the producer will produce event with character The UI events of string form feeding event message queue produce step;
For receiving the character string in event message queue as consumer, and the corresponding event representated by character string is entered Row framing produces data frame, is re-used as the UI event processing steps of the data frame feeding instruction queue that the producer will produce;
Data frame for receiving instruction queue as consumer, the data frame serial ports is sent to slave computer;Connect simultaneously The serial data of slave computer transmission is received, and the data is activation of data receiver queue is sent into as the serial data that the producer will receive With receiving step;
For receiving the data in data receiver queue as consumer and using analysis state machine to data receiving queue In data parsed, and as the producer will parse obtain data feeding parsing frame queue data analyzing step;
For receiving the data in parsing frame queue and the data displaying for being shown as the producer.
The UI events produce step to specifically include:
Action for perceiving human-computer interaction interface control by application affairs structure function, produces event, and to the thing The step of part is identified by being worth change;
For joining the team array function using the action of each control as an event branch by element, by each event branch The step of corresponding event command is stored in event message queue with character string forms.
The UI event processing steps are specifically included:
The step of for obtaining event message queue by element dequeue function;
For by element array function of joining the team that event branch is corresponding with conditional branching, and group is carried out according to protocol frame requirement Frame, data frame to be sent is turned into after CRC16 is verified, and is sent into after data frame to be sent is bundled with command string and referred to The step of making queue.
The data is activation is specifically included with receiving step:
Join for carrying out VISA serial ports parameter, baud rate parameter, data bit parameter, stop position by serial ports configuration module Number, the initial configuration of check bit parameter and Row control parameter and disable respective attributes node in serial ports transceiving data in case Only the step of configuration change;
For the data frame of instruction queue and the life of binding to be obtained by element dequeue function by serial ports sending module Character string is made, command string is judged into branch for construction of condition, data frame is write into serial ports by VISA sends to bottom The step of machine;
The serial data of slave computer is read for the VISA by serial ports receiver module, and the slave computer data of reading are sent The step of entering data receiver queue;
Function is closed for the VISA by serial ports closedown module to close serial ports, to recover disabled during initial configuration Attribute node the step of.
The data analyzing step is specifically included:
The step of for obtaining the data in data receiver queue by element dequeue function;
The step of for being parsed to the data in data receiving queue by analysis state machine;
Bundled with command string for being parsed analysis state machine after the data for obtaining are converted to character string by function The step of cluster feeding parsing frame queue;
The data displaying is specifically included:
The step of for obtaining the data in parsing frame queue by element dequeue function;
Releasing binding is carried out for parsing the data in frame queue by function pair, command character is series-connected to condition knot The branch selector of structure function, after data character string is converted into byte arrays, the step of display.
Advantages of the present invention:In device or method of the present invention, UI events generation module leads to UI event processing modules Event message queue communication is crossed, UI event processing modules are communicated with data is activation with receiver module by instruction queue, data hair Send with receiver module and data resolution module by data receiver queue communication, data resolution module passes through with data disaply moudle Parsing frame queue communication, forms four layers of producer consumer framework and the execution of each modular concurrent, data resolution module or step The data received to serial ports using the method for analysis state machine are parsed according to parsing Frame Protocol and obtain complete parsing data frame, are protected The integrality of communication data transfer is demonstrate,proved, program simple and clear, execution speed are fast and stable.
The present invention realizes that serial ports is received, sent and parsing display using producer consumer framework and state machine, it is ensured that Ensure that program is succinct while data are from losing, operation is time-consuming short.On the one hand it use four layers between five functional modules Producer consumer framework, program orderliness is clear and takes full advantage of the advantage of LabVIEW executed in parallel, improves operation speed Rate;On the other hand data are parsed using analysis state machine, solves the reception data occurred often in conventional program It is incomplete or for empty and program is lengthy and jumbled time-consuming the problems such as, high degree optimizes serial communication program.
Brief description of the drawings
Fig. 1 is the Organization Chart of the serial communication based on LabVIEW of the present invention;
Fig. 2 is the stopping mode schematic diagram of the program of the serial communication based on LabVIEW of the present invention;
Fig. 3 is the schematic diagram of data is activation and receiver module.
Specific embodiment
Specific embodiment one:With reference to Fig. 1 and Fig. 2 explanation present embodiments, it is based on described in present embodiment The serial communication device of LabVIEW, the communicator realizes the communication with slave computer as host computer, and it includes:
Action for perceiving human-computer interaction interface control, produce event and as the producer will produce event with character String form sends into the UI events generation module 1 of event message queue;
For receiving the character string in event message queue as consumer, and the corresponding event representated by character string is entered Row framing produces data frame, is re-used as the UI event processing modules 2 of the data frame feeding instruction queue that the producer will produce;
Data frame for receiving instruction queue as consumer, the data frame serial ports is sent to slave computer;Connect simultaneously The serial data of slave computer transmission is received, and the data is activation of data receiver queue is sent into as the serial data that the producer will receive With receiver module 3;
For receiving the data in data receiver queue as consumer and using analysis state machine to data receiving queue In data parsed, and as the producer will parse obtain data feeding parsing frame queue data resolution module 4;
For receiving the data in parsing frame queue and the data disaply moudle 5 for being shown as the producer.
Specific embodiment two:With reference to Fig. 1 and Fig. 2 explanation present embodiments, present embodiment is to implementation method one It is described further, the UI events generation module 1 is specifically included:
Action for perceiving human-computer interaction interface control, produces event, and the event is identified by being worth change Application affairs structure function;
For using the action of each control as an event branch, by each corresponding event command of event branch with word The element that symbol string form is stored in event message queue is joined the team array function.
In present embodiment, the application affairs structure function of UI events generation module 1 on human-computer interaction interface panel to respectively controlling The action of part is identified by being worth change event, and the action of each control is used as an event branch, and it is right that each branch produces The event command answered simultaneously is stored in event message queue now with character string forms by the element that LabVIEW is carried array function of joining the team UI events generation module 1 is used as the producer.
Specific embodiment three:With reference to Fig. 1 and Fig. 2 explanation present embodiments, present embodiment is to implementation method one Or two be described further, the UI event processing modules 2 are specifically included:
Element dequeue function for obtaining event message queue;
For event branch is corresponding with conditional branching, and framing is carried out according to protocol frame requirement, after CRC16 is verified As data frame to be sent, the element enqueue of instruction queue will be sent into after data frame to be sent and command string binding Function.
In present embodiment, UI event processing modules 2 obtain event message by the element dequeue function in LabVIEW The data of queue, now UI event processing modules 2 are used as consumer, and application conditions structure function is only to realize each event correspondence A conditional branching is found, framing is carried out according to protocol frame requirement according to event, the data frame for obtaining turns into after CRC16 is verified Data frame to be sent, using showing that control is shown frame to be sent with hexadecimal string in man-machine interface panel Show, while being joined the team after array function bundlees data frame with command string by the element that LabVIEW is carried sends into instruction queue, Now UI event processing modules 2 are used as the producer.
Specific embodiment four:Present embodiment is illustrated with reference to Fig. 1 to Fig. 3, present embodiment is to implementation method three It is described further, the data is activation is specifically included with receiver module 3:
For carry out VISA serial ports parameter, baud rate parameter, data bit parameter, stop position parameter, check bit parameter and The initial configuration of Row control parameter simultaneously disables respective attributes node in serial ports transceiving data to prevent the configuration change Serial ports configuration module;
For obtaining the data frame of instruction queue and the command string of binding by element dequeue function, by command word Symbol string judges branch for construction of condition, and data frame is write into serial ports by VISA sends to the serial ports sending module of slave computer;
Serial data for reading slave computer by VISA, and the slave computer data that will be read send into data receiver queue Serial ports receiver module;
Serial ports is closed for closing function by VISA, to recover the string of during initial configuration disabled attribute node Mouth closedown module.
Present embodiment includes serial ports configuration module, serial ports sending module, serial ports receiver module and serial ports closedown module, Serial ports configuration module carries out VISA serial ports, baud rate, data bit, stop position, check bit sum Row control these parameters Initial configuration and these configurations when serial ports is received and dispatched are forbidden to be changed by disabling the method for respective attributes node;Serial ports is sent out Module is sent to pass through the data that the element dequeue function in LabVIEW obtains instruction queue, now data is activation and receiver module 3 After as consumer, data solution is bundled, command string judges branch for construction of condition, and data character string is used to be sent to Slave computer, the serial ports function VISA that is carried using LabVIEW carries out transceiving data, is write by VISA and sent the data to down Position machine;Serial ports receiver module is read in real time to read back slave computer data by VISA and is shown to man-machine interface panel and sends into data Receiving queue, now data is activation and receiver module 3 are used as the producer;Serial port module is closed to close function by VISA to close Serial ports, while recovering each parameter attribute node disabled during initialization.
Specific embodiment five:Present embodiment is illustrated with reference to Fig. 1 to Fig. 3, present embodiment is to implementation method four It is described further, the data resolution module 4 is specifically included:
Element dequeue function for obtaining the data in data receiver queue;
For the analysis state machine parsed to the data in data receiving queue;
Sent into command string binding cluster after for the data that the parsing of analysis state machine is obtained to be converted into character string Parse the function of frame queue;
The data disaply moudle 5 is specifically included:
Element dequeue function for obtaining the data in parsing frame queue;
For carrying out releasing binding to the data in parsing frame queue, command character is series-connected to construction of condition function Branch selector, after data character string is converted into byte arrays, the function for being shown.
The branch selector is on construction of condition function.
In present embodiment, shown in Fig. 3, data resolution module 4 obtains string by the element dequeue function in LabVIEW The data that mouth reads back, are parsed by protocol analysis state machine, and now data resolution module 4 is used as consumer, data parsing The outermost layer of module 4 is that while is circulated to maintain the operation of state machine, and secondary outer layer is a construction of condition, for judging whether to surpass When, next layer is that for is circulated so that the data in obtaining the data receiver queue that data resolution module 4 is received are in the form of byte Parsed into circulation one by one, be construction of condition in for circulation internal layers, sentenced for the state different to each Disconnected, data have been processed under each state can indicate which state is next step enter, here it is the function of shift register, will Next state is delivered in recurrent state judgement next time;Data resolution module 4 obtains the data of data receiver queue, passes through Character string to byte arrays transfer function converts data to byte arrays, and then the feeding for circulations of byte one by one, this When data resolution module as consumer;The data that serial ports reads back parse frame by being obtained after state machine, and parsing frame number group turns Frame queue is parsed with command string binding cluster feeding after being changed to character string, now data resolution module 4 is used as the producer.
The outer layer of data disaply moudle 5 is that while circulates to ensure the operation of display module, and internal layer is construction of condition, data Display module 5 obtains the data in parsing frame queue by the element dequeue function in LabVIEW, is carried out after dequeuing data row Binding is released, command character therein is series-connected to the branch selector of construction of condition, and data character string is converted into byte arrays It is used to show afterwards, now data disaply moudle 5 is used as consumer.
In applying the invention to Practical Project, the communication of slave computer and host computer is realized, and then by before in host computer The operation of panel carrys out controlled motor operation:
Using the serial communication framework shown in Fig. 1, form four layers of producer consumer framework and each modular concurrent is performed, UI Event generation module 1 perceives the action of front panel control, produces event and event is sent into character string forms as the producer Event message queue, UI event processing modules 2 receive character string and relatively each thing in event message queue as consumer Part carries out framing, and this is ground floor producer consumer framework, and UI event processing modules 2 are re-used as the data that the producer will produce Frame sends into instruction queue, and data is activation receives the data in instruction queue and carries out serial ports transmission with receiver module 3 as consumer And serial data is received, this is second layer producer consumer framework, and data is activation is re-used as the producer with receiver module 3 will be connect Receive data feeding data receiver queue, data resolution module 4 as consumer receive data receiver queue in data simultaneously Parsed, this is third layer producer consumer framework, data resolution module 4 is re-used as the producer and will parse the data for obtaining In feeding parsing frame queue, data disaply moudle 5 receives the data in parsing frame queue and is shown as the producer, and this is 4th layer of producer consumer framework.
The outer layer of UI events generation module 1 is that while is circulated to maintain the operation of event generation module, is adopted in while circulations Event structure function is used, the corresponding control of front panel is added to correspondence by right button selection addition event branch on time structure block diagram Event branch, produce and event message is sent to by element array function of joining the team after corresponding event message and the binding of variant constant In queue, now UI events generation module 1 is used as the producer.
As shown in Fig. 2 the serial communication framework of LabVIEW has multithreading, so the mode of stopping is using circulation expiry notification The mode of device, i.e., use " obtain notifying device quote " function outside each circulation, UI event generation modules " ' stopping ' value changes Becoming " branch uses " send notify " function to send the notice that stop button is pressed to give expiry notification device, and will by expiry notification device This notice is delivered to the outermost layer while circulations of each thread, will notify to be assigned to while by " wait and notifying " function " cycling condition " button of circulation, the operation of whole program is terminated with this.
The outermost layer of UI event processing modules 2 is that while is circulated to ensure the operation of this module, in reception event message queue Data command character is series-connected to the branch selector of construction of condition after releasing binding, now UI event processing modules 2, as consumer, framing are carried out in corresponding conditional branching according to protocol frame standard.Using array function by frame to be sent One byte arrays of composition simultaneously add CRC check, and present case is verified using CRC16, and core concept is to utilize " to call built-in function section Point " generates the check bit of 16bit come the .dll files for calling the CRC16 for having generated to verify.The data obtained after the completion of framing On the one hand frame number group cycles through " numerical value to hexadecimal string is changed " function and enters back into next for circulations into for, The hexadecimal transmission frame character string for display is obtained by " connection string " function, by showing control in front panel Display;On the other hand instruction queue is sent into command string binding after being converted into character string, now UI event processing modules 2 are made It is the producer.
As shown in figure 3, serial ports sending module and serial ports receiver module are in a while circulation, while circulations ensure to receive The continuity of hair.
The outermost layer of data resolution module 4 maintains the operation of analysis state machine with while circulations, outer right in while circulations State and data used are initialized, and are successively respectively construction of condition from outside to inside in while circulations and are judged that element goes out Whether queue is overtime, for circulations make the data for receiving be processed one by one with bytewise, construction of condition selection state And the treatment of data and the selection to NextState under each state, state and data flow are followed flowing in and out while Ring and for use shift register when circulating, this ensure that under indicating next step to enter after data have been processed under each state One designated state.In outer layer while circulations, data resolution module read data words symbol string from data receiver queue turns For circulations are sent into one by one after changing byte arrays into, and now used as consumer, byte is circulated data resolution module 4 into for Enter first branches of states of acquiescence afterwards, judged according to parsing Frame Protocol, it is first determined whether be frame head, according to result Enter which state below determination in innermost layer construction of condition and choose whether for this secondary data to be added to parsing frame number group, In the condition adjudgement that this state passes through the incoming alternative condition structure of recurrent state next time of shift register, such state machine can Freely changed between each state, finally give the parsing data frame array according to protocol frame requirement and array is converted into word Parsing frame queue is sent into after symbol string and command string binding, now data resolution module 4 is used as the producer.
Data disaply moudle 5 is made up of the while circulations of outer layer and the construction of condition of internal layer, each serves as maintenance display mould Block runs and selects the effect of display content.Data disaply moudle 5 is solved after obtaining the data in parsing frame queue to data Bundling operation, command string feeding condition selector, data character string is converted into byte arrays latter aspect and is circulated into for By " numerical value to hexadecimal string change " function enter back into next for cycle through " connection string " function come To the hexadecimal parsing frame character string for display, and by showing that control shows in front panel, on the other hand according to condition Branch's content to display and parsing Frame Protocol are operated to parsing array of data, mainly using character string function " interception The LabVIEW such as character string ", dialog box function " single button dialog box " carry out requiring the whole of display content to different from tape function Close, now data disaply moudle 5 is used as consumer.
Specific embodiment six:With reference to Fig. 1 and Fig. 2 explanation present embodiments, it is based on described in present embodiment The serial port communication method of LabVIEW, the communication means is used to realize the communication of host computer and slave computer, and it includes:
Action for perceiving human-computer interaction interface control, produce event and as the producer will produce event with character The UI events of string form feeding event message queue produce step;
For receiving the character string in event message queue as consumer, and the corresponding event representated by character string is entered Row framing produces data frame, is re-used as the UI event processing steps of the data frame feeding instruction queue that the producer will produce;
Data frame for receiving instruction queue as consumer, the data frame serial ports is sent to slave computer;Connect simultaneously The serial data of slave computer transmission is received, and the data is activation of data receiver queue is sent into as the serial data that the producer will receive With receiving step;
For receiving the data in data receiver queue as consumer and using analysis state machine to data receiving queue In data parsed, and as the producer will parse obtain data feeding parsing frame queue data analyzing step;
For receiving the data in parsing frame queue and the data displaying for being shown as the producer.
Specific embodiment seven:With reference to Fig. 1 and Fig. 2 explanation present embodiments, present embodiment is to implementation method six It is described further, the UI events produce step to specifically include:
Action for perceiving human-computer interaction interface control by application affairs structure function, produces event, and to the thing The step of part is identified by being worth change;
For joining the team array function using the action of each control as an event branch by element, by each event branch The step of corresponding event command is stored in event message queue with character string forms.
Specific embodiment eight:With reference to Fig. 1 and Fig. 2 explanation present embodiments, present embodiment is to implementation method six Or seven be described further, the UI event processing steps are specifically included:
The step of for obtaining event message queue by element dequeue function;
For by element array function of joining the team that event branch is corresponding with conditional branching, and group is carried out according to protocol frame requirement Frame, data frame to be sent is turned into after CRC16 is verified, and is sent into after data frame to be sent is bundled with command string and referred to The step of making queue.
Specific embodiment nine:Present embodiment is illustrated with reference to Fig. 1 to Fig. 3, present embodiment is to implementation method eight It is described further, the data is activation is specifically included with receiving step:
Join for carrying out VISA serial ports parameter, baud rate parameter, data bit parameter, stop position by serial ports configuration module Number, the initial configuration of check bit parameter and Row control parameter and disable respective attributes node in serial ports transceiving data in case Only the step of configuration change;
For the data frame of instruction queue and the life of binding to be obtained by element dequeue function by serial ports sending module Character string is made, command string is judged into branch for construction of condition, data frame is write into serial ports by VISA sends to bottom The step of machine;
The serial data of slave computer is read for the VISA by serial ports receiver module, and the slave computer data of reading are sent The step of entering data receiver queue;
Function is closed for the VISA by serial ports closedown module to close serial ports, to recover disabled during initial configuration Attribute node the step of.
Specific embodiment ten:Present embodiment is illustrated with reference to Fig. 1, present embodiment is made into one to implementation method nine Step explanation, the data analyzing step is specifically included:
The step of for obtaining the data in data receiver queue by element dequeue function;
The step of for being parsed to the data in data receiving queue by analysis state machine;
Bundled with command string for being parsed analysis state machine after the data for obtaining are converted to character string by function The step of cluster feeding parsing frame queue;
The data displaying is specifically included:
The step of for obtaining the data in parsing frame queue by element dequeue function;
Releasing binding is carried out for parsing the data in frame queue by function pair, command character is series-connected to condition knot The branch selector of structure function, after data character string is converted into byte arrays, the step of display.
Serial port communication method based on LabVIEW is applied in Practical Project, realizes the communication of slave computer and host computer, is entered And the process phase in specific method and the specific embodiment five run come controlled motor by the operation of front panel in host computer Together.

Claims (6)

1. a kind of serial communication device based on LabVIEW, the serial communication device is realized and slave computer as host computer Communication, it is characterised in that it includes:
Action for perceiving human-computer interaction interface control, produce event and as the producer will produce event with character string shape Formula sends into the UI event generation modules of event message queue;
For receiving the character string in event message queue as consumer, and the corresponding event representated by character string is carried out into group Frame produces data frame, is re-used as the UI event processing modules of the data frame feeding instruction queue that the producer will produce;
Data frame for receiving instruction queue as consumer, the data frame is sent to slave computer by serial ports;Connect simultaneously The serial data of slave computer transmission is received, and the data is activation of data receiver queue is sent into as the serial data that the producer will receive With receiver module;
For receiving the data in data receiver queue as consumer and using analysis state machine in data receiving queue Data are parsed, and the data resolution module of the data feeding parsing frame queue for obtaining will be parsed as the producer;
Data resolution module outermost layer maintains the operation of analysis state machine with while circulations, while circulations it is outer to state with And data used are initialized, successively it is respectively from outside to inside in while circulations and judges element dequeue with construction of condition Whether time-out, with for circulate the data for receiving is processed one by one with bytewise, with construction of condition select state And the treatment of data and the selection to NextState under each state, state and data are flowing in and out while circulations Shift register is used when being circulated with for, this ensure that indicating next step to enter next after data have been processed under each state Individual designated state;In outer layer while circulations, data resolution module read data words symbol string, conversion from data receiver queue For circulations are sent into after into byte arrays one by one, now data resolution module is used as consumer, after byte enters for circulations Into first branches of states of acquiescence, judged according to parsing Frame Protocol, it is first determined whether being frame head, existed according to result Determine to enter which state below in innermost layer construction of condition and choose whether for this secondary data to be added to parsing frame number group, this By in the condition adjudgement of the incoming alternative condition structure of recurrent state next time of shift register, such state machine can be with for individual state Freely changed between each state, finally give the parsing data frame array according to protocol frame requirement and array is converted into character Parsing frame queue is sent into after string and command string binding, now data resolution module is used as the producer;
For receiving the data in parsing frame queue and the data disaply moudle for being shown as the producer.
2. the serial communication device based on LabVIEW according to claim 1, it is characterised in that the UI events are produced Module is specifically included:
Action for perceiving human-computer interaction interface control, produces event, and to the event by answering that value change is identified Use event structure function;
For using the action of each control as an event branch, by each corresponding event command of event branch with character string The element that form is stored in event message queue is joined the team array function.
3. the serial communication device based on LabVIEW according to claim 1 and 2, it is characterised in that at the UI events Reason module is specifically included:
Element dequeue function for obtaining event message queue;
For event branch is corresponding with conditional branching, and framing is carried out according to protocol frame requirement, turned into after CRC16 is verified Data frame to be sent, will send into the element enqueue letter of instruction queue after data frame to be sent and command string binding Number.
4. a kind of serial port communication method based on LabVIEW, the serial port communication method is performed on host computer, and its feature exists In it includes:
Action for perceiving human-computer interaction interface control, produce event and as the producer will produce event with character string shape The UI events of formula feeding event message queue produce step;
For receiving the character string in event message queue as consumer, and the corresponding event representated by character string is carried out into group Frame produces data frame, is re-used as the UI event processing steps of the data frame feeding instruction queue that the producer will produce;
Data frame for receiving instruction queue as consumer, the data frame is sent to slave computer by serial ports;Connect simultaneously The serial data of slave computer transmission is received, and the data is activation of data receiver queue is sent into as the serial data that the producer will receive With receiving step;
For receiving the data in data receiver queue as consumer and using analysis state machine in data receiving queue Data are parsed, and the data analyzing step of the data feeding parsing frame queue for obtaining will be parsed as the producer;
Data analyzing step outermost layer maintains the operation of analysis state machine with while circulations, while circulations it is outer to state with And data used are initialized, successively it is respectively from outside to inside in while circulations and judges element dequeue with construction of condition Whether time-out, with for circulate the data for receiving is processed one by one with bytewise, with construction of condition select state And the treatment of data and the selection to NextState under each state, state and data are flowing in and out while circulations Shift register is used when being circulated with for, this ensure that indicating next step to enter next after data have been processed under each state Individual designated state;In outer layer while circulations, data analyzing step read data words symbol string, conversion from data receiver queue For circulations are sent into after into byte arrays one by one, now data analyzing step is used as consumer, after byte enters for circulations Into first branches of states of acquiescence, judged according to parsing Frame Protocol, it is first determined whether being frame head, existed according to result Determine to enter which state below in innermost layer construction of condition and choose whether for this secondary data to be added to parsing frame number group, this By in the condition adjudgement of the incoming alternative condition structure of recurrent state next time of shift register, such state machine can be with for individual state Freely changed between each state, finally give the parsing data frame array according to protocol frame requirement and array is converted into character Parsing frame queue is sent into after string and command string binding, now data resolution module is used as the producer;
For receiving the data in parsing frame queue and the data displaying for being shown as the producer.
5. the serial port communication method based on LabVIEW according to claim 4, it is characterised in that the UI events are produced Step is specifically included:
Action for perceiving human-computer interaction interface control by application affairs structure function, produces event, and logical to the event The step of crossing value change and be identified;
For joining the team array function using the action of each control as an event branch by element, by each event branch correspondence Event command the step of be stored in event message queue with character string forms.
6. the serial port communication method based on LabVIEW according to claim 4 or 5, it is characterised in that at the UI events Reason step is specifically included:
The step of for obtaining event message queue by element dequeue function;
For by element array function of joining the team that event branch is corresponding with conditional branching, and framing is carried out according to protocol frame requirement, Turn into data frame to be sent after CRC16 is verified, instruction will be sent into after data frame to be sent and command string binding The step of queue.
CN201410246988.XA 2014-06-05 2014-06-05 Serial communication device and method based on LabVIEW Active CN103984665B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410246988.XA CN103984665B (en) 2014-06-05 2014-06-05 Serial communication device and method based on LabVIEW

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410246988.XA CN103984665B (en) 2014-06-05 2014-06-05 Serial communication device and method based on LabVIEW

Publications (2)

Publication Number Publication Date
CN103984665A CN103984665A (en) 2014-08-13
CN103984665B true CN103984665B (en) 2017-06-20

Family

ID=51276648

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410246988.XA Active CN103984665B (en) 2014-06-05 2014-06-05 Serial communication device and method based on LabVIEW

Country Status (1)

Country Link
CN (1) CN103984665B (en)

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104461879B (en) * 2014-11-28 2018-02-16 北京经纬恒润科技有限公司 A kind of automatic test approach and device
CN107302531A (en) * 2017-06-19 2017-10-27 青岛华潞佳电子科技有限公司 A kind of serial port command analytic method based on state machine and circle queue
CN107229591B (en) * 2017-06-22 2020-08-18 湖南省力宇燃气动力有限公司 Multi-serial port communication method and device
CN108989351B (en) * 2018-09-01 2021-04-16 西安科技大学 Data communication method and system for dual-redundancy motor measurement and control
CN111078420B (en) * 2019-10-14 2023-06-27 惠州市德赛西威汽车电子股份有限公司 Method for calling structure body function in dynamic link library based on LabVIEW
CN112433714A (en) * 2020-12-03 2021-03-02 宁波拓普集团股份有限公司 Software system architecture based on LabVIEW real-time system
CN113407214B (en) * 2021-06-24 2023-04-07 广东泰坦智能动力有限公司 Reconfigurable multithreading parallel upper computer system based on can communication
CN114994529A (en) * 2022-05-23 2022-09-02 淮阴工学院 LabVIEW-based motor measurement and control system and monitoring interface design method
CN115344396B (en) * 2022-10-19 2023-02-28 势加透博(成都)科技有限公司 Synchronous control method and device between panels based on LabVIEW
CN116165352B (en) * 2023-04-23 2023-07-21 河北华清环境科技集团股份有限公司 Quality control system of flue gas on-line monitor

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1688970A (en) * 2003-05-16 2005-10-26 微软公司 User interface automation framework classes and interfaces
CN101646083A (en) * 2009-06-18 2010-02-10 杭州高特信息技术有限公司 High-efficiency AVS video code stream analyzing system and method thereof

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8891852B2 (en) * 2004-06-09 2014-11-18 Cognex Technology And Investment Corporation Method and apparatus for configuring and testing a machine vision detector

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1688970A (en) * 2003-05-16 2005-10-26 微软公司 User interface automation framework classes and interfaces
CN101646083A (en) * 2009-06-18 2010-02-10 杭州高特信息技术有限公司 High-efficiency AVS video code stream analyzing system and method thereof

Also Published As

Publication number Publication date
CN103984665A (en) 2014-08-13

Similar Documents

Publication Publication Date Title
CN103984665B (en) Serial communication device and method based on LabVIEW
CN104750063B (en) For configuring the system and industrial safety system collocation method of industry security relay
CN101771700B (en) Modbus protocol communication node based on FPGA
CN104408002B (en) Serial ports master-slave communication control system and method
CN104899150B (en) Automated testing method and system and automation platform based on object-oriented
CN102967815A (en) Chip testing method, automated testing equipment and system
CN101222732B (en) State control signal testing device
CN110223643A (en) Data transmission method, component and system, display device
CN109307833A (en) Apparatus for testing chip and chip detecting method
CN109683882A (en) NB-IOT terminal software development approach under visible environment based on mobile terminal
CN112118158A (en) Test method, test device, test equipment and storage medium of switch
CN105071990B (en) A kind of general information system interface test method and device
CN102981827A (en) Display interface data treatment method and platform based on middle piece
CN103064328A (en) Digital pulse power supply synchronous timing trigger system
CN107070911A (en) The method and traffic comprehensive monitoring system of a kind of information transfer
CN104507100B (en) A method of Zigbee network is managed using wireless terminal
CN103135989A (en) Callback function code generation method and device
CN105591839A (en) Device, method and system of testing network exchange chip
CN106354611A (en) Monitoring device of terminal network state
CN113835946B (en) Pressure test method for data exchange
CN103544108A (en) System and method for testing embedded software integration strength
CN109887263A (en) Data transmission method, device, equipment and storage medium
CN103488601B (en) A kind of clock delay, data access method, system and equipment
CN202818323U (en) Base band NPZ code error detector based on FPGA chip
CN205121274U (en) Serial ports stipulations message signal testing terminal row

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
CB03 Change of inventor or designer information

Inventor after: Wang Qiang

Inventor after: The king is to give Han

Inventor after: Xue Honglin

Inventor after: Wu Zhaojun

Inventor before: Xue Honglin

Inventor before: Wang Qiang

Inventor before: Wu Zhaojun

Inventor before: Luo Jing

COR Change of bibliographic data
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20210407

Address after: Room 206-10, building 16, 1616 Chuangxin Road, Songbei District, Harbin City, Heilongjiang Province

Patentee after: Harbin jizuo technology partnership (L.P.)

Patentee after: Harbin Institute of Technology Asset Management Co.,Ltd.

Address before: 150001 No. 92 West straight street, Nangang District, Heilongjiang, Harbin

Patentee before: HARBIN INSTITUTE OF TECHNOLOGY

TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20210618

Address after: Room 206-12, building 16, 1616 Chuangxin Road, Songbei District, Harbin City, Heilongjiang Province

Patentee after: Harbin Institute of Technology Institute of artificial intelligence Co.,Ltd.

Address before: Room 206-10, building 16, 1616 Chuangxin Road, Songbei District, Harbin City, Heilongjiang Province

Patentee before: Harbin jizuo technology partnership (L.P.)

Patentee before: Harbin Institute of Technology Asset Management Co.,Ltd.