baud rate identification method of NMEA data

文档序号:1711809 发布日期:2019-12-13 浏览:16次 中文

阅读说明:本技术 一种nmea数据的波特率识别方法 (baud rate identification method of NMEA data ) 是由 徐俊杰 娄方 于 2019-09-06 设计创作,主要内容包括:本发明提供一种NMEA数据的波特率识别方法,包括以下步骤:S1、用户设置:根据船舶电子设备的输出数据波特率的设置主要列表和次要列表;S2、列表设置:主要列表、次要列表均以及分别对应序号设置的波特率;S3、识别模式:根据选择判断是否进入自动识别模式;S4、读取主要列表:设定主要列表的序号初始值n=0;S5、主要列表序号:设定主要列表的序号当前值n=n+1;并判断序号当前值n是否大于N;S6、读取次要列表:设定主要列表的序号初始值m=0;S7、次要列表序号:设定主要列表的序号当前值m=m+1;并判断序号当前值m是否大于M;根据获取的波特率接收船舶电子设备的输出数据输出字符语句;根据字符语句判断是否得到正确数据;具有操作简单方便的优点。(the invention provides a baud rate identification method of NMEA data, which comprises the following steps: s1, setting by the user: setting a primary list and a secondary list according to the baud rate of the output data of the ship electronic equipment; s2, list setting: the primary list, the secondary list and the baud rates respectively corresponding to the serial numbers are set; s3, recognizing the mode: judging whether to enter an automatic identification mode according to the selection; s4, read main list: setting the initial value n of the serial number of the main list to be 0; s5, primary list number: setting the current value n of the serial number of the main list as n + 1; judging whether the current value N of the serial number is greater than N; s6, read secondary list: setting the initial value m of the serial number of the main list to be 0; s7, minor list number: setting the current value m of the serial number of the main list as m + 1; judging whether the current value M of the serial number is greater than M; receiving output data output character sentences of the ship electronic equipment according to the obtained baud rate; judging whether correct data is obtained or not according to the character sentences; has the advantages of simple and convenient operation.)

1. a baud rate identification method of NMEA data is characterized by comprising the following steps:

s1, setting by the user: setting a primary list and a secondary list according to the baud rate of the output data of the ship electronic equipment;

s2, list setting: the main list comprises serial numbers 1, 2, 3, … and N, and baud rates respectively corresponding to the serial numbers; the secondary lists comprise serial numbers 1, 2, 3, … and M and baud rates respectively corresponding to the serial numbers; n and M are positive integers;

S3, recognizing the mode: judging whether to enter an automatic recognition mode according to the selection,

if yes, go to S4;

if not, returning to S1;

s4, read main list: setting the initial value n of the serial number of the main list to be 0;

S5, primary list number: setting the current value n of the serial number of the main list as n + 1; and judges whether the current value N of the sequence number is greater than N,

If yes, go to S6;

If not, outputting the baud rate corresponding to the current value n of the serial number, and entering S8;

s6, read secondary list: setting the initial value m of the serial number of the main list to be 0;

s7, minor list number: setting the current value m of the serial number of the main list as m + 1; and judges whether the current value M of the sequence number is greater than M,

if yes, prompting that the identification is not carried out, and ending;

if not, outputting the baud rate corresponding to the current value m of the serial number, and entering S10;

S8, main identification data: receiving output data output character sentences of the ship electronic equipment according to the obtained baud rate;

S9, judging whether the correct data consistent with the output data of the electronic equipment of the receiving ship is obtained according to the character sentence,

if so, saving the current baud rate, and finishing by taking the current baud rate as a working state;

if not, returning to S5;

S10, secondary identification data: receiving output data output character sentences of the ship electronic equipment according to the obtained baud rate;

s11, judging whether the correct data consistent with the output data of the electronic equipment of the receiving ship is obtained according to the character sentence,

If so, saving the current baud rate, and finishing by taking the current baud rate as a working state;

if not, the process returns to S7.

2. the method as claimed in claim 1, wherein in S1, the baud rate is set in the primary list with a higher frequency and the secondary list with a lower frequency according to the frequency of using the baud rate of the output data of the ship electronic device.

3. the method of claim 1, wherein said step of outputting said character sentence in S8 and S10 comprises the steps of:

s101, acquiring characters: receiving output data of the ship electronic equipment according to the baud rate corresponding to the current value n of the output serial number;

S102, reading a first character: reads the first character of the output data and determines whether it is correct,

if yes, entering S103;

if not, resetting S102;

s103, reading subsequent characters: the character pointer +1 stores the previous character and continues to read the current character;

s104, stopping reading: it is determined whether the current character is the last character of the output data,

If yes, resetting the character pointer and outputting the whole character sentence according to the read character;

If not, return to 103.

Technical Field

The invention belongs to the technical field of data transmission, and particularly relates to a baud rate identification method for NMEA data.

background

Electronic equipment in the boats and ships needs the data of external other electronic equipment under many conditions to the electron chart for example, need receive GPS or big dipper location data, compass position data, AIS automatic identification system data, depth finder data, log program data and radar ARPA data. The baud rates of output data of various devices are different, and even if the same device is used, the output baud rates of different brands can also be different, so that an operation manual of the output device needs to be consulted on site, the test is frequently carried out at different baud rates until the correct baud rate is identified, and a large amount of work is brought to site wiring and debugging.

disclosure of Invention

the invention aims to provide a baud rate identification method of NMEA data, which aims to solve the problem that field wiring and debugging are troublesome and laborious due to different data transmission baud rates of the data of the conventional electronic equipment in a ship which is externally connected with other electronic equipment.

the invention provides the following technical scheme:

a baud rate identification method for NMEA data comprises the following steps:

S1, setting by the user: setting a primary list and a secondary list according to the baud rate of the output data of the ship electronic equipment;

S2, list setting: the main list comprises serial numbers 1, 2, 3, … and N, and baud rates respectively corresponding to the serial numbers; the secondary lists comprise serial numbers 1, 2, 3, … and M and baud rates respectively corresponding to the serial numbers; n and M are positive integers;

s3, recognizing the mode: judging whether to enter an automatic identification mode according to the selection, and if so, entering S4; if not, returning to S1;

s4, read main list: setting the initial value n of the serial number of the main list to be 0;

s5, primary list number: setting the current value n of the serial number of the main list as n + 1; judging whether the current value N of the serial number is greater than N, if so, entering S6; if not, outputting the baud rate corresponding to the current value n of the serial number, and entering S8;

s6, read secondary list: setting the initial value m of the serial number of the main list to be 0;

S7, minor list number: setting the current value m of the serial number of the main list as m + 1; judging whether the current value M of the serial number is greater than M, if so, prompting that the serial number is not identified, and ending; if not, outputting the baud rate corresponding to the current value m of the serial number, and entering S10;

S8, main identification data: receiving output data output character sentences of the ship electronic equipment according to the obtained baud rate;

s9, judging whether correct data consistent with output data of the electronic equipment of the receiving ship is obtained or not according to the character sentences, if so, saving the current baud rate, and finishing by taking the current baud rate as a working state; if not, returning to S5;

s10, secondary identification data: receiving output data output character sentences of the ship electronic equipment according to the obtained baud rate;

s11, judging whether correct data consistent with output data of the electronic equipment of the receiving ship is obtained or not according to the character sentences, if so, saving the current baud rate, and finishing by taking the current baud rate as a working state; if not, the process returns to S7.

further, in S1, according to the frequency of use of the baud rate of the output data of the ship electronic device, the frequency is set in the primary list higher and the frequency is set in the secondary list lower.

further, in S8 and S10, the outputting the character sentence includes the following steps:

s101, acquiring characters: receiving output data of the ship electronic equipment according to the baud rate corresponding to the current value n of the output serial number;

s102, reading a first character: reading the first character of the output data and judging whether the first character is correct, if so, entering S103; if not, resetting S102;

s103, reading subsequent characters: the character pointer +1 stores the previous character and continues to read the current character;

s104, stopping reading: judging whether the current character is the last character of the output data, if so, resetting the character pointer and outputting the whole character sentence according to the read character; if not, return to 103.

the invention has the beneficial effects that:

the invention is used for data reception of electronic equipment, in particular for automatic identification of the baud rate of the NMEA data of a ship, and saves debugging time by automatically identifying the baud rate of the data from the outside and memorizing the state; therefore, the tedious operation that a user manually tries to explore the baud rate is avoided, wherein the baud rate which is automatically identified is the common baud rate.

Drawings

the accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the description serve to explain the principles of the invention and not to limit the invention. In the drawings:

FIG. 1 is a schematic flow diagram of the process of the present invention;

FIG. 2 is a flow chart of a method for outputting a character sentence according to the present invention;

FIG. 3 is a schematic diagram of a detailed description of a principal list;

FIG. 4 is a diagram of an embodiment secondary list;

Fig. 5 is a configuration of a transmission data format according to an embodiment.

Detailed Description

As shown in fig. 1, a baud rate identification method for NMEA data includes the following steps:

s1, setting by the user: setting a primary list and a secondary list according to the baud rate of the output data of the ship electronic equipment; allowing a user to define the baud rate which is preferentially identified, allowing the user to define the range of the baud rate, and allowing the user to manually select the baud rate;

S2, list setting: the main list comprises serial numbers 1, 2, 3, … and N, and baud rates respectively corresponding to the serial numbers; the secondary lists comprise serial numbers 1, 2, 3, … and M and baud rates respectively corresponding to the serial numbers; n and M are positive integers; as in the main list shown in fig. 3, the first row represents the sequence number and the second row represents the baud rate bps; as in the secondary list shown in fig. 4, the first row represents the sequence number and the second row represents the baud rate bps; the working personnel use the frequency according to the baud rate of the output data of the ship electronic equipment, wherein the frequency is higher and is arranged in the primary list, and the frequency is lower and is arranged in the secondary list;

S3, recognizing the mode: judging whether to enter an automatic recognition mode according to the selection,

If yes, go to S4;

if not, returning to S1;

S4, read main list: setting the initial value n of the serial number of the main list to be 0;

S5, primary list number: setting the current value n of the serial number of the main list as n + 1; and judges whether the current value N of the sequence number is greater than N,

if yes, go to S6;

if not, outputting the baud rate corresponding to the current value n of the serial number, and entering S8;

S6, read secondary list: setting the initial value m of the serial number of the main list to be 0;

s7, minor list number: setting the current value m of the serial number of the main list as m + 1; and judges whether the current value M of the sequence number is greater than M,

if yes, prompting that the identification is not carried out, and ending;

If not, outputting the baud rate corresponding to the current value m of the serial number, and entering S10;

s8, main identification data: receiving output data output character sentences of the ship electronic equipment according to the obtained baud rate;

s9, judging whether the correct data consistent with the output data of the electronic equipment of the receiving ship is obtained according to the character sentence,

If so, saving the current baud rate, and finishing by taking the current baud rate as a working state;

if not, returning to S5;

s10, secondary identification data: receiving output data output character sentences of the ship electronic equipment according to the obtained baud rate;

s11, judging whether the correct data consistent with the output data of the electronic equipment of the receiving ship is obtained according to the character sentence,

if so, saving the current baud rate, and finishing by taking the current baud rate as a working state;

if not, the process returns to S7.

As shown in fig. 2, in S8 and the S10, outputting the character sentence includes the steps of:

s101, acquiring characters: receiving output data of the ship electronic equipment according to the baud rate corresponding to the current value n of the output serial number;

S102, reading a first character: reads the first character of the output data and determines whether it is correct,

if yes, entering S103;

if not, resetting S102;

s103, reading subsequent characters: the character pointer +1 stores the previous character and continues to read the current character;

S104, stopping reading: it is determined whether the current character is the last character of the output data,

if yes, resetting the character pointer and outputting the whole character sentence according to the read character;

if not, return to 103.

according to the requirements of IEC61162-1 Maritime navigation and radio communication requests and systems-Digital interfaces Part 1: Single talk and multiplex transmitters, the format of the transmission data consists of three parts, as shown in FIG. 5,

1, Start bit Start bit 1 bit

2, Data content Data bits 8 bits

3 Stop bit 1 bit

wherein the data content is formatted as follows

(frame command start bit) aaccc, ddd, ddd, … … xh < CR > < LF >

1, frame command start bit, is "$" or "! "

2, aaccc, address field, aa address field (e.g. SD for depth finder), ccc statement name (e.g. DPT for depth measurement).

3, is a checksum prefix

4, hh, checksum (check sum), which is the checksum of all characters between $ and x (each byte is subjected to exclusive or operation to obtain the checksum, and then converted into 16-ary ASCLL characters).

5, < CR > < LF > is a carriage return and line feed character indicating the end of this frame character.

the following is an example of data for a depth finder, starting at $ followed by 5 ASCLL characters, followed by numbers, letters, and commas, prefixed by a checksum, and 19 a checksum (check sum).

for example: JLDBT,0011.0, F,0003.4, M,001.8, F19

First, determine that the received character is $ or! If no read is received, continue to wait for receipt if $ or! Then, more than 3 ASCLL characters can be continuously received, and the polarity of the received data is correct during the table displaying; upon receipt of $ or! And then, continuing to receive the following characters until < CR > < LF > is received, and receiving and outputting the whole line of character strings.

Although the present invention has been described in detail with reference to the foregoing embodiments, it will be apparent to those skilled in the art that changes may be made in the embodiments and/or equivalents thereof without departing from the spirit and scope of the invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

9页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种Chirp调制信号的信道估计和均衡方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类