Control rod serial port drive design method based on windows under vxworks system

文档序号:960717 发布日期:2020-11-03 浏览:12次 中文

阅读说明:本技术 vxworks系统下基于windml的操纵杆串口驱动设计方法 (Control rod serial port drive design method based on windows under vxworks system ) 是由 高娟 于 2020-07-09 设计创作,主要内容包括:本发明属于vxworks系统技术领域,具体涉及一种vxworks系统下基于windml的操纵杆串口驱动设计方法。其首先配置windml虚拟鼠标设备;其次,基于windml虚拟鼠标设备实现操纵杆串口驱动;包括:初始化串口设备使用环境;解析串口数据获取操纵杆发送的力敏调节坐标;根据操纵杆回弹过程速率过滤回弹力敏调节坐标值;将过滤后的力敏坐标值转为系统鼠标事件;通过以上步骤,实现操纵杆在vxwork系统下的串口驱动功能。与现有技术相比较,本发明简化了操纵杆串口驱动加载过程,针对操纵杆力敏移动位移特点过滤回弹过程数据,缩短了操纵杆移动事件转化为鼠标事件的响应时间,同时可兼容其他类型鼠标配置使用,并保证了系统的接口性能和安全性。(The invention belongs to the technical field of vxworks systems, and particularly relates to a control rod serial port drive design method based on a windows system. Firstly, configuring a windows virtual mouse device; secondly, realizing the serial port driving of the operating lever based on the windows virtual mouse device; the method comprises the following steps: initializing a serial port equipment use environment; analyzing serial port data to obtain force-sensitive adjusting coordinates sent by the operating lever; filtering the resilience force sensitive adjustment coordinate value according to the resilience process rate of the operating lever; converting the filtered force-sensitive coordinate values into system mouse events; through the steps, the serial port driving function of the operating rod under the vxwork system is realized. Compared with the prior art, the invention simplifies the loading process of the serial port drive of the operating lever, filters the data of the rebound process aiming at the force-sensitive movement displacement characteristic of the operating lever, shortens the response time of converting the operating lever movement event into the mouse event, is compatible with other types of mouse configurations for use, and ensures the interface performance and the safety of the system.)

1. A control rod serial port drive design method based on a windows system under a vxworks system is characterized by comprising the following steps:

step1: configuring a windows virtual mouse device;

in order to enable a vxworks system to simulate a joystick movement event into a system mouse event, and simultaneously to enable the vxworks system to be compatible with other types of mice which are normally used and not occupy system events of other types of mice, virtual mouse equipment needs to be added into a windows configuration file; the purpose of converting the operating rod movement event into the mouse movement event is realized by calling the mouse event of the virtual mouse device;

step2: realizing the serial port driving of a control lever based on the Windows virtual mouse device; the step2 comprises the following steps:

step 21: initializing a serial port equipment use environment;

step 22: analyzing serial port data to obtain force-sensitive adjusting coordinates sent by the operating lever;

step 23: filtering the resilience force sensitive adjustment coordinate value according to the resilience process rate of the operating lever;

step 24: converting the filtered force-sensitive coordinate values into system mouse events;

through the steps, the serial port driving function of the operating rod under the vxwork system is realized.

2. The method for designing a joystick serial port drive based on a windows (R) ml under a vxworks system according to claim 1, wherein the step1 specifically comprises:

step 11: creating a windows project;

step 12: opening config.windows file adding display equipment in engineering, and adding a PS2 or UBS mouse according to requirements;

step 13: open the manual add virtual mouse device configuration statement in config.

3. The method for designing a windows-based joystick serial port drive in a vxworks system as claimed in claim 1, wherein said step 21 comprises:

firstly, in equipment connected with a vxworks system, a serial port equipment descriptor communicated with a control rod is appointed;

secondly, opening serial port equipment communicated with the operating rod through a vxworks system function;

then, configuring baud rate and check bit parameters of the serial port;

and finally, establishing a serial port receiving task to receive the joystick serial port data.

4. The method for designing a windows-based joystick serial port drive under a vxworks system as claimed in claim 3, wherein said step 22 comprises:

firstly, receiving a task through a serial port, and acquiring the content of a mobile event data message sent by a control rod device;

then, the legality of the message is verified, and the illegal message is subjected to sliding window processing, so that the packet loss rate of serial port data is reduced; and if the message is legal, acquiring the force-sensitive adjusting coordinates (x, y) of the operating rod relative to the central point in the moving event data message content.

5. The method for designing a windows-based joystick serial port drive under a vxworks system as claimed in claim 4, wherein said step 23 comprises:

firstly, estimating the maximum distance MLS of single-point movement according to the data rate sent by the serial port of the operating lever;

then, calculating the single-point movement displacement of the coordinate point relative to the last coordinate point;

and secondly, comparing the single-point moving displacement with the coordinate points of the MLS filtering springback process, and filtering the springback force sensitive adjustment coordinate values.

6. The method of designing a windows-based joystick serial drive under a vxworks system as claimed in claim 5, wherein said step 24 comprises:

firstly, multiplying the relative displacement of the force-sensitive coordinate point and the central point on X and Y axes by a proportional value rate to obtain the relative mouse moving point of the joystick;

then, the mouse moving point is used as an input parameter of a mouse event function of the virtual mouse device;

and finally, simulating a system mouse event by calling a mouse event function of the virtual mouse device.

7. The method for designing a joystick serial port drive based on a windows (ml) under a vxworks system according to claim 3, wherein in the process of creating a serial port receiving task to receive joystick serial port data in the step 21, an ioctl function of the vxworks system is cyclically used to judge whether new data is received at the serial port; and when the receiving length is larger than zero, reading the serial port data by using a read function.

8. The method for designing a joystick serial port drive based on a windows system according to claim 4, wherein in the step 22, the correct joystick force-sensitive coordinate value can be obtained only after the message validity judgment of serial port data obtained by a serial port receiving task, which is specifically as follows:

storing all serial port data received this time to a temporary array Temp;

sequentially processing each data in the temporary array Temp, counting the total number count of legal data, judging whether the frame head meets the requirement when the total count is the number of the frame head, storing the frame head into a buffer array, and setting the total count to be 1 if the frame head does not meet the requirement, and continuing to process subsequent data; when the total count is the frame length, judging whether the frame end and the checksum meet the requirement, if so, calculating the force-sensitive adjusting coordinate (x, y) of the operating rod and setting the total count to be 0, otherwise, continuously searching a second frame head from the first frame head position z1 to the position pointed by the total count in the buffer array: if the frame length is found, all data after the position z2 of the second frame header are shifted to the array header, and the frame length minus z2 is assigned to count; if not found, setting the count to 1;

and judging whether the number of processed serial port data is smaller than the number of the serial port data received this time, if so, continuing the processing, and if not, exiting the loop.

9. The method for designing a serial port drive of a joystick based on a windows system as claimed in claim 5, wherein in step 23, if the effective force-sensitive coordinate point data is obtained in step 22, it is determined whether the data belongs to the point data sent in the process of automatic rebound of the joystick; the method comprises the following specific steps:

setting the total displacement of the operating rod moving left and right as S0 and the total displacement of the operating rod moving up and down as S1; the number of the points sent by the operating lever in each rebound process is N, the average distance of the abscissa between the points is D0 which is S0/N, and the average distance of the ordinate is D1 which is S1/N;

if the coordinates of the center point are (x0, y0), the currently received force-sensitive coordinate point is (x2, y2), and the last received force-sensitive coordinate point is (x1, y1), D0 ═ x1-x2|, D1 ═ y1-y2|, and the sizes of D0 and D0 and the sizes of D1 and D1 are determined; when D0< D0 and D1< D1, the force-sensitive coordinate point is judged to meet the requirement.

10. The method for designing a serial port drive of a joystick based on a windows (R) ml under a vxworks system as claimed in claim 6, wherein in step 23, if the force-sensitive coordinate point data of the non-rebound process is obtained in step 23, the joystick movement event is simulated into a system mouse event; the method comprises the following specific steps:

calculating a coordinate point of a screen cursor according to the force-sensitive coordinate point;

setting a conversion ratio value rate, wherein the moving direction of the operating lever is positive left, negative right, positive top and negative bottom;

x3 (x0-x2) rate, y3 (y2-y0) rate of the coordinate points of the screen cursor;

and taking the coordinate point of the screen cursor as the input of a virtual mouse event to simulate a system mouse event.

Technical Field

The invention belongs to the technical field of vxworks systems, and particularly relates to a control rod serial port drive design method based on a windows system.

Background

The vxwork operating system is an embedded operating system, and the WindML graphic library programming is a main means for developing graphics and human-computer interaction interfaces under vxworks. The joystick is used as a common input device in a weapon system, and the direction control of the upper part, the lower part, the left part and the right part is realized by pulling a handle of the joystick for a certain angle.

In order to enable the joystick device to be normally used as a serial device in a vxworks system, the problem of serial driving of the joystick needs to be solved. The current mature joystick driving technology is realized based on a windows multi-pointer, joystick equipment is used as a standard serial port driver of a low-level input driver using system, the content of the driver uses a high-level input driver, and the same driving design is carried out on a joystick of a serial port by simulating a windows message mechanism of a ps/2 mouse; however, the method is not compatible with usb type mice, the type of the access device by the system is limited, and meanwhile, the moving position of the joystick is inaccurate due to the fact that data of the rebound process of the joystick are not filtered.

In order to solve the problem of joystick serial port drive under the vxwork, to be compatible with other input mouse devices and simplify the drive event process, a joystick serial port drive design method based on a windows virtual mouse needs to be provided.

Disclosure of Invention

Technical problem to be solved

The technical problem to be solved by the invention is as follows: how to provide a joystick serial port drive design method based on a windows virtual mouse.

(II) technical scheme

In order to solve the technical problem, the invention provides a control rod serial port drive design method based on a windows system, which comprises the following steps:

step1: configuring a windows virtual mouse device;

in order to enable a vxworks system to simulate a joystick movement event into a system mouse event, and simultaneously to enable the vxworks system to be compatible with other types of mice which are normally used and not occupy system events of other types of mice, virtual mouse equipment needs to be added into a windows configuration file; the purpose of converting the operating rod movement event into the mouse movement event is realized by calling the mouse event of the virtual mouse device;

step2: realizing the serial port driving of a control lever based on the Windows virtual mouse device; the step2 comprises the following steps:

step 21: initializing a serial port equipment use environment;

step 22: analyzing serial port data to obtain force-sensitive adjusting coordinates sent by the operating lever;

step 23: filtering the resilience force sensitive adjustment coordinate value according to the resilience process rate of the operating lever;

step 24: converting the filtered force-sensitive coordinate values into system mouse events;

through the steps, the serial port driving function of the operating rod under the vxwork system is realized.

Wherein, the step1 specifically comprises:

step 11: creating a windows project;

step 12: opening config.windows file adding display equipment in engineering, and adding a PS2 or UBS mouse according to requirements;

step 13: open the manual add virtual mouse device configuration statement in config.

Wherein the step 21 comprises:

firstly, in equipment connected with a vxworks system, a serial port equipment descriptor communicated with a control rod is appointed;

secondly, opening serial port equipment communicated with the operating rod through a vxworks system function;

then, configuring baud rate and check bit parameters of the serial port;

and finally, establishing a serial port receiving task to receive the joystick serial port data.

Wherein the step 22 comprises:

firstly, receiving a task through a serial port, and acquiring the content of a mobile event data message sent by a control rod device;

then, the legality of the message is verified, and the illegal message is subjected to sliding window processing, so that the packet loss rate of serial port data is reduced; and if the message is legal, acquiring the force-sensitive adjusting coordinates (x, y) of the operating rod relative to the central point in the moving event data message content.

Wherein the step 23 comprises:

firstly, estimating the maximum distance MLS of single-point movement according to the data rate sent by the serial port of the operating lever;

then, calculating the single-point movement displacement of the coordinate point relative to the last coordinate point;

and secondly, comparing the single-point moving displacement with the coordinate points of the MLS filtering springback process, and filtering the springback force sensitive adjustment coordinate values.

Wherein the step 24 comprises:

firstly, multiplying the relative displacement of the force-sensitive coordinate point and the central point on X and Y axes by a proportional value rate to obtain the relative mouse moving point of the joystick;

then, the mouse moving point is used as an input parameter of a mouse event function of the virtual mouse device;

and finally, simulating a system mouse event by calling a mouse event function of the virtual mouse device.

In the process of creating the serial port receiving task to receive the joystick serial port data in the step 21, cyclically using an ioctl function of the vxworks system to judge whether new data is received at the serial port; and when the receiving length is larger than zero, reading the serial port data by using a read function.

In step 22, the correct joystick force-sensitive coordinate value can be obtained only after the message validity judgment of the serial port data obtained by the serial port receiving task, specifically:

storing all serial port data received this time to a temporary array Temp;

sequentially processing each data in the temporary array Temp, counting the total number count of legal data, judging whether the frame head meets the requirement when the total count is the number of the frame head, storing the frame head into a buffer array, and setting the total count to be 1 if the frame head does not meet the requirement, and continuing to process subsequent data; when the total count is the frame length, judging whether the frame end and the checksum meet the requirement, if so, calculating the force-sensitive adjusting coordinate (x, y) of the operating rod and setting the total count to be 0, otherwise, continuously searching a second frame head from the first frame head position z1 to the position pointed by the total count in the buffer array: if the frame length is found, all data after the position z2 of the second frame header are shifted to the array header, and the frame length minus z2 is assigned to count; if not found, setting the count to 1;

and judging whether the number of processed serial port data is smaller than the number of the serial port data received this time, if so, continuing the processing, and if not, exiting the loop.

In step 23, if the effective force-sensitive coordinate point data is obtained in step 22, it is determined whether the data belongs to the point data sent in the automatic rebounding process of the joystick; the method comprises the following specific steps:

setting the total displacement of the operating rod moving left and right as S0 and the total displacement of the operating rod moving up and down as S1; the number of the points sent by the operating lever in each rebound process is N, the average distance of the abscissa between the points is D0 which is S0/N, and the average distance of the ordinate is D1 which is S1/N;

if the coordinates of the center point are (x0, y0), the currently received force-sensitive coordinate point is (x2, y2), and the last received force-sensitive coordinate point is (x1, y1), D0 ═ x1-x2|, D1 ═ y1-y2|, and the sizes of D0 and D0 and the sizes of D1 and D1 are determined; when D0< D0 and D1< D1, the force-sensitive coordinate point is judged to meet the requirement.

In step 23, if the force-sensitive coordinate point data of the non-rebound process is obtained in step 23, simulating a joystick movement event into a system mouse event; the method comprises the following specific steps:

calculating a coordinate point of a screen cursor according to the force-sensitive coordinate point;

setting a conversion ratio value rate, wherein the moving direction of the operating lever is positive left, negative right, positive top and negative bottom;

x3 (x0-x2) rate, y3 (y2-y0) rate of the coordinate points of the screen cursor;

and taking the coordinate point of the screen cursor as the input of a virtual mouse event to simulate a system mouse event.

(III) advantageous effects

Compared with the prior art, the invention designs and realizes the control rod serial port drive based on the window under the vxoworks system according to the force sensitive displacement characteristic of the control rod equipment and combining the window library aiming at the system platform characteristic under the application scene that the system is vxworks. The invention simplifies the loading process of the serial port drive of the operating lever, filters the data of the rebound process aiming at the force-sensitive movement displacement characteristic of the operating lever, shortens the response time of converting the operating lever movement event into the mouse event, is compatible with other types of mouse configurations for use, and ensures the interface performance and the safety of the system.

Drawings

Fig. 1 is a flow chart of the implementation of the joystick serial port drive.

Detailed Description

In order to make the objects, contents, and advantages of the present invention clearer, the following detailed description of the embodiments of the present invention will be made in conjunction with the accompanying drawings and examples.

In order to solve the problems of the prior art, the invention provides a control rod serial port drive design method based on a windows (Windows) under a vxworks system, which is used for solving the control rod serial port drive problem under a vxworks system platform; as shown in fig. 1, the method comprises the steps of:

step1: configuring a windows virtual mouse device;

in order to enable a vxworks system to simulate a joystick movement event into a system mouse event, and simultaneously to enable the vxworks system to be compatible with other types of mice which are normally used and not occupy system events of other types of mice, virtual mouse equipment needs to be added into a windows configuration file; the purpose of converting the operating rod movement event into the mouse movement event is realized by calling the mouse event of the virtual mouse device;

step2: realizing the serial port driving of a control lever based on the Windows virtual mouse device; the step2 comprises the following steps:

step 21: initializing a serial port equipment use environment;

step 22: analyzing serial port data to obtain force-sensitive adjusting coordinates sent by the operating lever;

step 23: filtering the resilience force sensitive adjustment coordinate value according to the resilience process rate of the operating lever;

step 24: converting the filtered force-sensitive coordinate values into system mouse events;

through the steps, the serial port driving function of the operating rod under the vxwork system is realized.

Wherein, the step1 specifically comprises:

step 11: creating a windows project;

step 12: opening config.windows file adding display equipment in engineering, and adding a PS2 or UBS mouse according to requirements;

step 13: open the manual add virtual mouse device configuration statement in config.

Wherein the step 21 comprises:

firstly, in equipment connected with a vxworks system, a serial port equipment descriptor communicated with a control rod is appointed;

secondly, opening serial port equipment communicated with the operating rod through a vxworks system function;

then, configuring baud rate and check bit parameters of the serial port;

and finally, establishing a serial port receiving task to receive the joystick serial port data.

Wherein the step 22 comprises:

firstly, receiving a task through a serial port, and acquiring the content of a mobile event data message sent by a control rod device;

then, the legality of the message is verified, and the illegal message is subjected to sliding window processing, so that the packet loss rate of serial port data is reduced; and if the message is legal, acquiring the force-sensitive adjusting coordinates (x, y) of the operating rod relative to the central point in the moving event data message content.

Wherein the step 23 comprises:

firstly, estimating the maximum distance MLS of single-point movement according to the data rate sent by the serial port of the operating lever;

then, calculating the single-point movement displacement of the coordinate point relative to the last coordinate point;

and secondly, comparing the single-point moving displacement with the coordinate points of the MLS filtering springback process, and filtering the springback force sensitive adjustment coordinate values.

Wherein the step 24 comprises:

firstly, multiplying the relative displacement of the force-sensitive coordinate point and the central point on X and Y axes by a proportional value rate to obtain the relative mouse moving point of the joystick;

then, the mouse moving point is used as an input parameter of a mouse event function of the virtual mouse device;

and finally, simulating a system mouse event by calling a mouse event function of the virtual mouse device.

In the process of creating the serial port receiving task to receive the joystick serial port data in the step 21, cyclically using an ioctl function of the vxworks system to judge whether new data is received at the serial port; and when the receiving length is larger than zero, reading the serial port data by using a read function.

In step 22, the correct joystick force-sensitive coordinate value can be obtained only after the message validity judgment of the serial port data obtained by the serial port receiving task, specifically:

storing all serial port data received this time to a temporary array Temp;

sequentially processing each data in the temporary array Temp, counting the total number count of legal data, judging whether the frame head meets the requirement when the total count is the number of the frame head, storing the frame head into a buffer array, and setting the total count to be 1 if the frame head does not meet the requirement, and continuing to process subsequent data; when the total count is the frame length, judging whether the frame end and the checksum meet the requirement, if so, calculating the force-sensitive adjusting coordinate (x, y) of the operating rod and setting the total count to be 0, otherwise, continuously searching a second frame head from the first frame head position z1 to the position pointed by the total count in the buffer array: if the frame length is found, all data after the position z2 of the second frame header are shifted to the array header, and the frame length minus z2 is assigned to count; if not, setting the count to 1 (when the frame header has two bytes, the last data is assigned to the first digit of the array);

and judging whether the number of processed serial port data is smaller than the number of the serial port data received this time, if so, continuing the processing, and if not, exiting the loop.

In step 23, if the effective force-sensitive coordinate point data is obtained in step 22, it is determined whether the data belongs to the point data sent in the automatic rebounding process of the joystick; the method comprises the following specific steps:

setting the total displacement of the operating rod moving left and right as S0 and the total displacement of the operating rod moving up and down as S1; the number of the points sent by the operating lever in each rebound process is N, the average distance of the abscissa between the points is D0 which is S0/N, and the average distance of the ordinate is D1 which is S1/N;

if the coordinates of the center point are (x0, y0), the currently received force-sensitive coordinate point is (x2, y2), and the last received force-sensitive coordinate point is (x1, y1), D0 ═ x1-x2|, D1 ═ y1-y2|, and the sizes of D0 and D0 and the sizes of D1 and D1 are determined; when D0< D0 and D1< D1, the force-sensitive coordinate point is judged to meet the requirement.

In step 23, if the force-sensitive coordinate point data of the non-rebound process is obtained in step 23, simulating a joystick movement event into a system mouse event; the method comprises the following specific steps:

calculating a coordinate point of a screen cursor according to the force-sensitive coordinate point;

setting a conversion ratio value rate, wherein the moving direction of the operating lever is positive left, negative right, positive top and negative bottom;

x3 (x0-x2) rate, y3 (y2-y0) rate of the coordinate points of the screen cursor;

and taking the coordinate point of the screen cursor as the input of a virtual mouse event to simulate a system mouse event.

11页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:vxworks系统下基于信号量事件的操纵杆串口驱动设计方法

网友询问留言

已有0条留言

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

精彩留言,会给你点赞!

技术分类