CN115952001A - Android system based can communication method, device and equipment - Google Patents

Android system based can communication method, device and equipment Download PDF

Info

Publication number
CN115952001A
CN115952001A CN202310023346.2A CN202310023346A CN115952001A CN 115952001 A CN115952001 A CN 115952001A CN 202310023346 A CN202310023346 A CN 202310023346A CN 115952001 A CN115952001 A CN 115952001A
Authority
CN
China
Prior art keywords
data
communication
receiving
communication library
sending
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.)
Pending
Application number
CN202310023346.2A
Other languages
Chinese (zh)
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.)
XIAMEN FOUR-FAITH COMMUNICATION TECHNOLOGY CO LTD
Original Assignee
XIAMEN FOUR-FAITH COMMUNICATION TECHNOLOGY CO LTD
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by XIAMEN FOUR-FAITH COMMUNICATION TECHNOLOGY CO LTD filed Critical XIAMEN FOUR-FAITH COMMUNICATION TECHNOLOGY CO LTD
Priority to CN202310023346.2A priority Critical patent/CN115952001A/en
Publication of CN115952001A publication Critical patent/CN115952001A/en
Pending legal-status Critical Current

Links

Images

Abstract

The invention provides a can communication method, a device and equipment based on an android system, which comprise the following steps: when the property change of the system is monitored, calling a can parameter configuration service to configure can parameters of the system, and initializing a can communication library, wherein the can communication library runs on a native layer; calling the can communication library to initialize a can data receiving and sending FIFO channel and creating a can receiving and sending service thread; the method comprises the steps of obtaining calling information of a can communication library interface, triggering a receiving service thread to receive data or sending service thread to send data, and solving the problem that an application program does not have root authority to use a can bus.

Description

Android system based can communication method, device and equipment
Technical Field
The invention relates to the field of can communication, in particular to a can communication method, device and equipment based on an android system.
Background
In the prior art, an android native system does not have any API to support the operation of a CAN bus, and under the condition that the system does not have special support, an application program needs to realize the use of a CAN bus interface on a native layer library, while the parameter configuration of the CAN bus interface needs root authority, which necessarily relates to the opening of the root authority of the system and the capability of the application program to grant the root authority, and the opening of the root authority of the system also necessarily has the risk of security.
In view of this, the present application is presented.
Disclosure of Invention
The invention discloses a can communication method, device and equipment based on an android system, and aims to solve the problem that an application program does not have root authority to use a can bus.
The first embodiment of the invention provides a can communication method based on an android system, which comprises the following steps:
when the property change of the system is monitored, calling a can parameter configuration service to configure can parameters of the system, and initializing a can communication library, wherein the can communication library runs on a native layer;
calling the can communication library to initialize a can data receiving and sending FIFO channel and creating a can receiving and sending service thread;
and acquiring the calling information of the can communication library interface, and triggering a receiving service thread to receive data or sending service thread to send data.
Preferably, when it is monitored that the system property attribute is changed, invoking the can parameter configuration service to configure the can parameters of the system specifically includes:
when the system is started, the init program monitors whether the property of the system is changed according to the rc file configuration;
if so, the can parameter configuration service calls a system ip tool to configure the can parameters of the system, wherein the can parameters comprise baud rate, up/down, triple-sampling switch and bus _ off timeout of the system can nodes.
Preferably, the initializing can communication library includes: initializing a CAN communication library, opening CAN equipment, setting CAN ID information to be filtered during communication according to parameters transmitted by an application program by the CAN communication library, and initializing the CAN ID of the terminal.
Preferably, the obtaining of the call information to the can communication library interface and the triggering of the receiving service thread to receive the data specifically include:
when the can device has data input, the device wakes up to block, reads the data of the can device into the receiving FIFO and triggers the receiving event to notify the callback function to read the data.
Preferably, the calling information of the can communication library interface is acquired, and the sending of the data by the sending service thread is specifically as follows:
when the data in the transmission FIFO is filled with the wake-up block, the data is read from the transmission FIFO and the data is transmitted by using the can communication library interface.
A second embodiment of the present invention provides a can communication apparatus based on an android system, including:
the parameter configuration unit is used for calling a can parameter configuration service to perform can parameter configuration on the system when monitoring that the property of the system changes, and initializing a can communication library, wherein the can communication library runs on a native layer;
the communication library initialization unit is used for calling the can communication library initialization can data receiving and sending FIFO channels and creating can receiving and sending service threads;
and the data receiving and sending unit is used for acquiring the calling information of the can communication library interface and triggering the receiving service thread to receive data or sending the service thread to send data.
Preferably, the parameter configuration unit is specifically configured to:
when the system is started, the init program monitors whether the property of the system is changed or not according to rc file configuration;
if so, the can parameter configuration service calls a system ip tool to configure the can parameters of the system, wherein the can parameters comprise baud rate, up/down, triple-sampling switch and bus _ off timeout of the system can nodes.
Preferably, the data transceiver unit is specifically configured to:
when the can device has data input, the device wakes up to block, reads the data of the can device into the receiving FIFO and triggers the receiving event to notify the callback function to read the data.
Preferably, the data transceiver unit is specifically configured to:
when the data in the transmission FIFO is filled with the wake-up block, the data is read from the transmission FIFO and the data is transmitted by using the can communication library interface.
The third embodiment of the invention provides an android system can communication device, which comprises a memory and a processor, wherein the memory stores a computer program, and the computer program can be executed by the processor to realize the android system can communication method.
Based on the android system can communication method, device and equipment provided by the invention, when the property of the monitoring system is changed during the system, can parameter configuration service is called to configure the can parameters of the system, a can communication library is initialized at the same time, after the can communication library is initialized, a can data receiving and transmitting FIFO channel is initialized through the can communication library, can receiving and transmitting service threads are established, and when the calling information of an interface of the can communication library is received, the receiving service thread is triggered to receive data or the transmitting service thread transmits data, so that the problem that an application program has no root authority to use a can bus is realized; the can communication library is packaged with the purposes of high cohesion and low coupling, high independence of the can communication library is achieved, and secondary development and use of third-party clients or application programs are met.
Drawings
Fig. 1 is a schematic flow chart of a can communication method based on an android system according to a first embodiment of the present invention;
fig. 2 is a block diagram of a can communication apparatus based on the android system according to a second embodiment of the present invention;
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be obtained by a person skilled in the art without making any creative effort based on the embodiments in the present invention, belong to the protection scope of the present invention.
For better understanding of the technical solutions of the present invention, the following detailed descriptions of the embodiments of the present invention are provided with reference to the accompanying drawings.
It should be understood that the described embodiments are only some embodiments of the invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terminology used in the embodiments of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in the examples of the present invention and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be understood that the term "and/or" as used herein is merely one type of association that describes an associated object, meaning that three relationships may exist, e.g., a and/or B may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter associated objects are in an "or" relationship.
The word "if" as used herein may be interpreted as "at 8230; \8230;" or "when 8230; \8230;" or "in response to a determination" or "in response to a detection", depending on the context. Similarly, the phrase "if determined" or "if detected (a stated condition or event)" may be interpreted as "upon determining" or "in response to determining" or "upon detecting (a stated condition or event)" or "in response to detecting (a stated condition or event)", depending on the context.
In the embodiments, the references to "first \ second" merely distinguish similar objects and do not represent a specific ordering for the objects, and it is to be understood that "first \ second" may interchange a specific order or sequence where permitted. It should be understood that "first \ second" distinguishing objects may be interchanged under appropriate circumstances such that the embodiments described herein may be implemented in sequences other than those illustrated or described herein.
The following detailed description of specific embodiments of the invention refers to the accompanying drawings.
The invention discloses a can communication method, device and equipment based on an android system, and aims to solve the problem that an application program does not have root authority to use a can bus.
Referring to fig. 1, a first embodiment of the present invention provides an android system can communication method, which is executed by an android system can communication device (hereinafter referred to as a communication device), and in particular, executed by one or more processors in the communication device, so as to implement at least the following steps:
s101, when the property change of the system is monitored, a can parameter configuration service is called to configure can parameters of the system, and a can communication library is initialized, wherein the can communication library runs on a native layer;
in this embodiment, the communication device may be a terminal having a data processing and analyzing capability, such as a desktop computer, a notebook computer, a server, and a workstation, wherein a corresponding operating system and application software may be installed in the communication device, and the functions required in this embodiment are implemented by the combination of the operating system and the application software.
Specifically, in this embodiment, when the system is started, the init program monitors whether the property of the system property is changed according to the rc file configuration;
if so, the can parameter configuration service calls a system ip tool to configure can parameters of the system, wherein the can parameters may include, but are not limited to, baud rate of a system can node, up/dowm, triple-sampling switch, and bus _ off timeout, and the can communication library runs on a native layer and can use jni to derive a java interface, initCan, canReadEven, canWriteData, and UninitCan interface; subsequent reading, writing and logout operations of the can equipment are realized by the application program through the handle returned after the InitCan, and the independence of the communication library module is improved.
It should be noted that the root authority is required by the system ip tool for parameter configuration of the baud rate, up/dowm, triple-sampling switch, bus _ off timeout, and the like of the system can node, and the setting of the property only requires the user-level authority, and the use of the can parameter configuration service to obtain the property to configure the can node parameter can effectively solve the problem that the application program has no root authority to realize the parameter configuration of the can node.
S102, calling the can communication library to initialize the cans data receiving and sending FIFO channels and creating a cans receiving and sending service thread;
it should be noted that, in this embodiment, the application program may call a can communication library initialization interface to initialize the can communication library, where initializing the can communication library includes:
1, initializing the can communication library and opening the can equipment;
setting CAN ID information to be filtered during CAN communication according to parameters transmitted by an application program by a CAN communication library, and initializing the CAN ID of the terminal;
3. the communication library initializes the can data transmit-receive FIFO channel, creates can receive and transmit service threads and returns initialization completion status information.
And S103, acquiring calling information of the can communication library interface, and triggering a receiving service thread to receive data or sending service thread to send data.
Note that, in this embodiment:
the application program can call the can communication library interface to send data; and the can communication library copies the data input by the interface to a transmission FIFO and triggers a transmission thread to transmit the data.
Specifically, the method comprises the following steps: the can sending thread blocks and waits for data sending, and when data is filled into the sending FIFO and awakens the block, the data is read from the sending FIFO and sent by using the can communication library interface; and when the can sending thread receives the exit signal, the execution thread exits.
The application program can also call a can communication library registration can data receiving event callback function, a can data receiving thread receives data and writes the data into a receiving FIFO and triggers an interface event, the registered receiving callback function is called, and the callback function takes away can data from the FIFO.
Specifically, the method comprises the following steps: the can receiving thread blocks to wait for receiving data, and when data input exists in the can equipment, the cann equipment data is read into a receiving FIFO and a receiving event is triggered to notify a callback function to read the data; the can receiving thread executes a thread exit upon receiving the exit signal.
The application program can also call the can communication library to end communication, specifically: the can communication library triggers the receiving and sending threads to exit, and waits for the receiving and sending threads to end; the can communication library destroys the transmit-receive FIFO, closes the can device, and initializes the communication library.
The above embodiment includes at least the following advantageous effects:
1. the property attribute is used for transmitting and configuring parameters between the can parameter configuration service and the application program, and the problem of can parameter configuration of the application program without root authority is effectively solved.
2. The can communication library runs on a native layer, is packaged in an independent modularization mode, and is convenient for secondary development and use.
3. The can communication library is used in combination with the FIFO to realize data receiving and transmitting double-thread asynchronous communication, so that the ANdroid application program is reasonably avoided from being improperly used, and the ANR problem is possibly caused.
4. The can receiving/sending thread runs in a blocking-awakening mode, so that the running effect of the program is effectively improved, and the CPU utilization rate is reduced, because the CPU resource is often limited in an embedded hardware system.
Referring to fig. 2, a second embodiment of the present invention provides an android system can communication device, including:
the parameter configuration unit 201 is configured to, when monitoring that the system property attribute changes, invoke a can parameter configuration service to perform can parameter configuration on the system, and initialize a can communication library, where the can communication library operates on a native layer;
a communication library initialization unit 202, configured to invoke the can communication library initialization can data receiving and sending FIFO channels, and create can receiving and sending service threads;
the data transceiver 203 is configured to acquire call information of the can communication library interface, and trigger the receiving service thread to receive data or send the service thread to send data.
Preferably, the parameter configuration unit is specifically configured to:
when the system is started, the init program monitors whether the property of the system is changed according to the rc file configuration;
if yes, the can parameter configuration service calls a system ip tool to configure can parameters of the system, wherein the can parameters comprise baud rate, up/dowm, triple-sampling switch and bus _ off timeout of system can nodes.
Preferably, the data transceiver unit is specifically configured to:
when the can device has data input, the device wakes up to block, reads the data of the can device into the receiving FIFO and triggers the receiving event to notify the callback function to read the data.
Preferably, the data transceiver unit is specifically configured to:
when the data in the transmission FIFO is filled with the wake-up block, the data is read from the transmission FIFO and the data is transmitted by using the can communication library interface.
The third embodiment of the invention provides an android system can communication device, which comprises a memory and a processor, wherein the memory stores a computer program, and the computer program can be executed by the processor to realize the android system can communication method.
Based on the android system can communication method, device and equipment provided by the invention, can parameter configuration service is called to configure can parameters of the system when the property of the system is monitored to change during the system, a can communication library is initialized at the same time, after the can communication library is initialized, a can data receiving and sending FIFO channel is initialized through the can communication library, a can receiving and sending service thread is created, and when the call information of an interface of the can communication library is received, the receiving service thread is triggered to receive data or send the service thread to send data, so that the problem that an application program has no root right to use a can bus is solved; the can communication library is packaged with the purposes of high cohesion and low coupling, high independence of the can communication library is achieved, and secondary development and use of third-party customers or application programs are met.
Illustratively, the computer programs described in the third and fourth embodiments of the present invention may be partitioned into one or more modules, which are stored in the memory and executed by the processor to implement the present invention. The one or more modules may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution process of the computer program in the android system can based communication device. For example, the device described in the second embodiment of the present invention.
The Processor may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc., the processor is the control center of the android system can communication method, and various interfaces and lines are used to connect the whole implementation to the various parts of the android system can communication method.
The memory may be used for storing the computer programs and/or modules, and the processor may implement various functions of an android system can communication method by running or executing the computer programs and/or modules stored in the memory and calling data stored in the memory. The memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, a text conversion function, etc.), and the like; the storage data area may store data (such as audio data, text message data, etc.) created according to the use of the cellular phone, etc. In addition, the memory may include high speed random access memory, and may also include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), at least one magnetic disk storage device, a Flash memory device, or other volatile solid state storage device.
Wherein the implemented module, if implemented in the form of a software functional unit and sold or used as a stand-alone product, can be stored in a computer readable storage medium. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments described above may be implemented. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U.S. disk, removable hard disk, magnetic diskette, optical disk, computer Memory, read-Only Memory (ROM), random Access Memory (RAM), electrical carrier wave signal, telecommunications signal, and software distribution medium, etc. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
It should be noted that the above-described device embodiments are merely illustrative, where the units described as separate parts may or may not be physically separate, and the parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. In addition, in the drawings of the embodiment of the apparatus provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, and may be specifically implemented as one or more communication buses or signal lines. One of ordinary skill in the art can understand and implement it without inventive effort.
The above description is only for the preferred embodiment of the present invention, but the scope of the present invention is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present invention are included in the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (10)

1. A can communication method based on an android system is characterized by comprising the following steps:
when the property change of the system is monitored, calling a can parameter configuration service to configure can parameters of the system, and initializing a can communication library, wherein the can communication library runs on a native layer;
calling the can communication library to initialize a can data receiving and sending FIFO channel and creating a can receiving and sending service thread;
and acquiring the calling information of the can communication library interface, and triggering a receiving service thread to receive data or sending service thread to send data.
2. The android system can communication method as claimed in claim 1, wherein the invoking of a can parameter configuration service to configure can parameters of a system when the change of system property is monitored is specifically:
when the system is started, the init program monitors whether the property of the system is changed or not according to rc file configuration;
if yes, the can parameter configuration service calls a system ip tool to configure can parameters of the system, wherein the can parameters comprise baud rate, up/dowm, triple-sampling switch and bus _ off timeout of system can nodes.
3. The android system can communication method of claim 1, wherein initializing the can repository comprises: initializing a CAN communication library, opening CAN equipment, setting CAN ID information to be filtered during communication according to parameters transmitted by an application program by the CAN communication library, and initializing the CAN ID of the terminal.
4. The android system can communication method as claimed in claim 1, wherein obtaining call information to a can communication library interface, triggering a receiving service thread to receive data specifically comprises:
when the can device has data input, the device wakes up to block, reads the data of the can device into the receiving FIFO and triggers the receiving event to notify the callback function to read the data.
5. The android system can communication method as claimed in claim 1, wherein the obtaining of call information to a can communication library interface, and the sending of data by the sending service thread is specifically:
when the data in the transmission FIFO is filled with the wake-up block, the data is read from the transmission FIFO and the data is transmitted by using the can communication library interface.
6. An android system can-based communication device, comprising:
the parameter configuration unit is used for calling a can parameter configuration service to perform can parameter configuration on the system when monitoring that the property of the system changes, and initializing a can communication library, wherein the can communication library runs on a native layer;
the communication library initialization unit is used for calling the can communication library initialization can data receiving and transmitting FIFO channels and creating can receiving and transmitting service threads;
and the data receiving and sending unit is used for acquiring the calling information of the can communication library interface and triggering the receiving service thread to receive data or sending the service thread to send data.
7. The android system can communication device of claim 1, wherein the parameter configuration unit is specifically configured to:
when the system is started, the init program monitors whether the property of the system is changed according to the rc file configuration;
if so, the can parameter configuration service calls a system ip tool to configure the can parameters of the system, wherein the can parameters comprise baud rate, up/down, triple-sampling switch and bus _ off timeout of the system can nodes.
8. The android system can communication device of claim 6, wherein the data transceiver is specifically configured to:
when the can device has data input, the device wakes up to block, reads the data of the can device into the receiving FIFO and triggers the receiving event to notify the callback function to read the data.
9. The android system can communication device of claim 6, wherein the data transceiver is specifically configured to:
when the data in the transmission FIFO is filled with the wake-up block, the data is read from the transmission FIFO and the data is transmitted by using the can communication library interface.
10. An android system can based communication device comprising a memory and a processor, the memory having stored therein a computer program executable by the processor to implement an android system can based communication method as claimed in any one of claims 1 to 5.
CN202310023346.2A 2023-01-09 2023-01-09 Android system based can communication method, device and equipment Pending CN115952001A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310023346.2A CN115952001A (en) 2023-01-09 2023-01-09 Android system based can communication method, device and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310023346.2A CN115952001A (en) 2023-01-09 2023-01-09 Android system based can communication method, device and equipment

Publications (1)

Publication Number Publication Date
CN115952001A true CN115952001A (en) 2023-04-11

Family

ID=87290628

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310023346.2A Pending CN115952001A (en) 2023-01-09 2023-01-09 Android system based can communication method, device and equipment

Country Status (1)

Country Link
CN (1) CN115952001A (en)

Similar Documents

Publication Publication Date Title
CN108256002B (en) Cross-machine-room data synchronization method, device, system and server
US8321723B2 (en) Methods and apparatus for event logging in an information network
US9612886B2 (en) Method and device for monitoring API function scheduling in mobile terminal
CN110958161B (en) Block chain link point monitoring method and device and storage medium
GB2518739A (en) Custom Correlation of a Distributed Business Transaction
CN111258847B (en) File handle monitoring and analyzing method, device, medium and equipment
CN111694677A (en) Message queue management method, device, terminal and computer-readable storage medium
CN110881224B (en) Network long connection method, device, equipment and storage medium
US8516094B2 (en) Method and network management apparatus for implementing information service level inheritance in network management system
CN115952001A (en) Android system based can communication method, device and equipment
CN109784041B (en) Event processing method and device, storage medium and electronic device
CN111813596A (en) Chip restarting method and device and computing equipment
CN116185799A (en) Interrupt time acquisition method, device, system, communication equipment and storage medium
CN108804152B (en) Method and device for adjusting configuration parameters
CN113114522B (en) Flow monitoring device
CN113032054B (en) Service execution method and device, storage medium and electronic device
CN113055493B (en) Data packet processing method, device, system, scheduling device and storage medium
CN116016653A (en) Information pushing method and device of blockchain, electronic equipment and storage medium
CN114218000A (en) Log management method and device, electronic equipment and computer readable storage medium
CN111556043B (en) Message processing method, device, system, equipment and readable storage medium
CN114371980A (en) Call link performance monitoring method and device, computer equipment and storage medium
CN114138371A (en) Configuration dynamic loading method and device, computer equipment and storage medium
CN113177202A (en) Data calling method and system, double-chip sales terminal and readable storage medium
WO2017186271A1 (en) Method and managing module for managing voice data generated by a call managing system
CN112612578A (en) Virtual machine monitoring method and device

Legal Events

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