CN112463690A - Method and device for realizing data transmission - Google Patents

Method and device for realizing data transmission Download PDF

Info

Publication number
CN112463690A
CN112463690A CN202011391577.1A CN202011391577A CN112463690A CN 112463690 A CN112463690 A CN 112463690A CN 202011391577 A CN202011391577 A CN 202011391577A CN 112463690 A CN112463690 A CN 112463690A
Authority
CN
China
Prior art keywords
data transmission
handle
usb
file descriptor
local interface
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
CN202011391577.1A
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.)
Suzhou Zhendi Intelligent Technology Co Ltd
Original Assignee
Suzhou Zhendi Intelligent 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 Suzhou Zhendi Intelligent Technology Co Ltd filed Critical Suzhou Zhendi Intelligent Technology Co Ltd
Priority to CN202011391577.1A priority Critical patent/CN112463690A/en
Publication of CN112463690A publication Critical patent/CN112463690A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/40Bus structure
    • G06F13/4063Device-to-bus coupling
    • G06F13/4068Electrical coupling
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4282Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2213/00Indexing scheme relating to interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F2213/0042Universal serial bus [USB]

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Information Transfer Systems (AREA)

Abstract

The application provides a method and a device for realizing data transmission, which are applied to the field of computers, wherein the method for realizing data transmission comprises the following steps: after an AOA mode is started by an android system of an equipment end, a file descriptor corresponding to the android system is obtained; transmitting the file descriptor to a JAVA local interface, and acquiring a handle corresponding to the file descriptor; and the handle is utilized to realize data transmission between the device side and the USB device in the JAVA local interface. In the above scheme, after the android system at the device end starts the AOA mode, the file descriptor is transmitted to the JAVA local interface, and the corresponding handle is acquired, so that the data transmission process can be implemented at the JAVA local interface at the bottom layer through the handle, and the middle two layers, i.e., the input layer and the output layer, are bypassed, thereby avoiding the influence of the bottom layer operation on the upper layer, and improving the stability of data transmission between the device end and the USB device in the access mode.

Description

Method and device for realizing data transmission
Technical Field
The present application relates to the field of computers, and in particular, to a method and an apparatus for implementing data transmission.
Background
In an Accessory Mode (access Mode), external USB hardware and an Android device are generally interacted by using a standard Mode in an official document, but for different mobile phone manufacturers, the speeds and the accuracy rates of USB insertion, USB extraction and USB wakeup are different, so that the problem of poor stability of data transmission between the Android device and the USB device is caused.
Disclosure of Invention
An object of the embodiments of the present application is to provide a method and an apparatus for implementing data transmission, so as to solve the technical problem that in an access mode, stability of data transmission between a device side and a USB device is poor.
In order to achieve the above purpose, the technical solutions provided in the embodiments of the present application are as follows:
in a first aspect, an embodiment of the present application provides a method for implementing data transmission, including: after an AOA mode is started by an android system of an equipment end, a file descriptor corresponding to the android system is obtained; transmitting the file descriptor to a JAVA local interface, and acquiring a handle corresponding to the file descriptor; and realizing data transmission between the equipment terminal and the USB equipment in the JAVA local interface by using the handle. In the above scheme, after the android system at the device end starts the AOA mode, the file descriptor is transmitted to the JAVA local interface, and the corresponding handle is acquired, so that the data transmission process can be implemented at the JAVA local interface at the bottom layer through the handle, and the middle two layers, i.e., the input layer and the output layer, are bypassed, thereby avoiding the influence of the bottom layer operation on the upper layer, and improving the stability of data transmission between the device end and the USB device in the access mode.
In an optional embodiment of the present application, the implementing, by using the handle, data transmission between the device side and the USB device in the JAVA local interface includes: and transmitting the data selected by the user to the USB equipment corresponding to the handle by using a reading function. In the above scheme, the read function can be used to implement data transmission between the device side and the USB device at the JAVA local interface of the bottom layer, thereby avoiding the influence of the bottom layer operation on the upper layer and improving the stability of data transmission between the device side and the USB device in the access mode.
In an optional embodiment of the present application, after the transmitting, by using the read function, the data selected by the user to the USB device corresponding to the handle, the method further includes: and if the return value of the reading function is larger than zero, determining that the data reading of the equipment terminal is successful. In the above scheme, if the return value of the read function is greater than zero, it indicates that the device side successfully transmits data to the USB device.
In an optional embodiment of the present application, the implementing, by using the handle, data transmission between the device side and the USB device in the JAVA local interface includes: and receiving the data transmitted by the USB equipment corresponding to the handle by using a write-in function. In the above scheme, the data transmission between the device side and the USB device can be implemented by using the write function at the JAVA local interface of the bottom layer, thereby avoiding the influence of the bottom layer operation on the upper layer, and improving the stability of data transmission between the device side and the USB device in the access mode.
In an optional embodiment of the present application, after the receiving, by using a write function, data transmitted by the USB device corresponding to the handle, the method further includes: and if the return value of the write-in function is larger than zero, determining that the data write-in of the equipment terminal is successful. In the above scheme, if the return value of the write function is greater than zero, it indicates that the device side successfully receives data from the USB device.
In an optional embodiment of the present application, after the implementing, by using the handle, the interaction between the device side and the USB device in the JAVA local interface, the method further includes: and if the return values of the read function and the write function are both larger than zero, determining that the data reading and writing of the equipment end are successful. In the above scheme, if the return values of the read function and the write function are both greater than zero, it indicates that the data transmission between the device side and the USB device is successful.
In an optional embodiment of the present application, the obtaining a handle corresponding to the file descriptor includes: acquiring member variables corresponding to the file descriptors; and converting the member variable into a handle corresponding to the file descriptor. In the above scheme, the corresponding handle can be obtained by obtaining the member variable corresponding to the file descriptor, so that the data transmission process can be realized at the bottom JAVA local interface through the handle, and the middle two layers, i.e., the input layer and the output layer, are bypassed, thereby avoiding the influence of the bottom operation on the upper layer, and improving the stability of data transmission between the device side and the USB device in the access mode.
In an optional embodiment of the present application, before the obtaining a file descriptor corresponding to the system, the method further includes: if an instruction for representing the insertion of the USB equipment is received, initiating AOA mode query to the system; and if an instruction for representing that a user confirms to open the AOA mode is received, the AOA mode is opened. In the above scheme, after the USB device is plugged in and the user confirms to open the AOA mode, the device side may open the AOA mode to implement data transmission between the device side and the USB device.
In a second aspect, an embodiment of the present application provides an apparatus for implementing data transmission, including: the device comprises a first acquisition module, a second acquisition module and a third acquisition module, wherein the first acquisition module is used for acquiring a file descriptor corresponding to an android system after the android system of an equipment end starts an AOA mode; the second acquisition module is used for transmitting the file descriptor to a JAVA local interface and acquiring a handle corresponding to the file descriptor; and the data transmission module is used for realizing data transmission between the equipment terminal and the USB equipment in the JAVA local interface by using the handle. In the above scheme, after the android system at the device end starts the AOA mode, the file descriptor is transmitted to the JAVA local interface, and the corresponding handle is acquired, so that the data transmission process can be implemented at the JAVA local interface at the bottom layer through the handle, and the middle two layers, i.e., the input layer and the output layer, are bypassed, thereby avoiding the influence of the bottom layer operation on the upper layer, and improving the stability of data transmission between the device end and the USB device in the access mode.
In an optional embodiment of the present application, the data transmission module is further configured to: and transmitting the data selected by the user to the USB equipment corresponding to the handle by using a reading function. In the above scheme, the read function can be used to implement data transmission between the device side and the USB device at the JAVA local interface of the bottom layer, thereby avoiding the influence of the bottom layer operation on the upper layer and improving the stability of data transmission between the device side and the USB device in the access mode.
In an optional embodiment of the present application, the apparatus for implementing data transmission further includes: and the first determining module is used for determining that the data reading of the equipment terminal is successful if the return value of the reading function is greater than zero. In the above scheme, if the return value of the read function is greater than zero, it indicates that the device side successfully transmits data to the USB device.
In an optional embodiment of the present application, the data transmission module is further configured to: and receiving the data transmitted by the USB equipment corresponding to the handle by using a write-in function. In the above scheme, the data transmission between the device side and the USB device can be implemented by using the write function at the JAVA local interface of the bottom layer, thereby avoiding the influence of the bottom layer operation on the upper layer, and improving the stability of data transmission between the device side and the USB device in the access mode.
In an optional embodiment of the present application, the apparatus for implementing data transmission further includes: and the second determining module is used for determining that the data writing of the equipment terminal is successful if the return value of the writing function is greater than zero. In the above scheme, if the return value of the write function is greater than zero, it indicates that the device side successfully receives data from the USB device.
In an optional embodiment of the present application, the apparatus for implementing data transmission further includes: and the third determining module is used for determining that the data reading and writing of the equipment terminal are successful if the return values of the read function and the write function are both greater than zero. In the above scheme, if the return values of the read function and the write function are both greater than zero, it indicates that the data transmission between the device side and the USB device is successful.
In an optional embodiment of the present application, the second obtaining module is further configured to: acquiring member variables corresponding to the file descriptors; and converting the member variable into a handle corresponding to the file descriptor. In the above scheme, the corresponding handle can be obtained by obtaining the member variable corresponding to the file descriptor, so that the data transmission process can be realized at the bottom JAVA local interface through the handle, and the middle two layers, i.e., the input layer and the output layer, are bypassed, thereby avoiding the influence of the bottom operation on the upper layer, and improving the stability of data transmission between the device side and the USB device in the access mode.
In an optional embodiment of the present application, the apparatus for implementing data transmission further includes: the query module is used for initiating AOA mode query to the system if receiving an instruction for representing the insertion of the USB equipment; and the starting module is used for starting the AOA mode if receiving an instruction for representing that a user confirms to start the AOA mode. In the above scheme, after the USB device is plugged in and the user confirms to open the AOA mode, the device side may open the AOA mode to implement data transmission between the device side and the USB device.
In a third aspect, an embodiment of the present application provides an electronic device, including: a processor, a memory, and a bus; the processor and the memory are communicated with each other through the bus; the memory stores program instructions executable by the processor, the processor invoking the program instructions capable of performing the method of implementing data transfer as in the first aspect.
In a fourth aspect, embodiments of the present application provide a non-transitory computer-readable storage medium storing computer instructions that cause the computer to perform the method of implementing data transmission as in the first aspect.
In order to make the aforementioned objects, features and advantages of the present application more comprehensible, embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments of the present application will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and that those skilled in the art can also obtain other related drawings based on the drawings without inventive efforts.
Fig. 1 is a flowchart of a method for implementing data transmission according to an embodiment of the present application;
fig. 2 is a flowchart of a specific implementation of step S102 provided in an embodiment of the present application;
fig. 3 is a flowchart of another method for implementing data transmission according to an embodiment of the present application;
fig. 4 is a block diagram illustrating an apparatus for implementing data transmission according to an embodiment of the present disclosure;
fig. 5 is a block diagram of an electronic device according to an embodiment of the present disclosure.
Detailed Description
Android (Android) has introduced support for the Android Open access Protocol (AOA) from version 3.1, where the AOA Protocol is a Protocol that allows external Universal Serial Bus (USB) hardware to interact with Android devices. The protocol expands the function of the USB interface of the Android device and provides conditions for the application of the intelligent device based on the Android system to the field of data acquisition and device control.
The Android system supports a variety of USB peripherals. According to the role of the Android device in the USB communication, the communication between the Android device and the USB device can be divided into a Host Mode (Host Mode) and an Accessory Mode (access Mode).
The access mode refers to that the Android device serves as a slave of the USB device, and the external device serves as a host and supplies power for the bus. In this mode, the external USB device is called an Android accessory. The mode provides the Android device without host function with the capability of interacting with the USB device. In the access mode, both the Android device and the Android Accessory must support the AOA protocol.
However, this standard model has many disadvantages, such as: due to different speeds and accuracy rates of inserting, pulling out and awakening the USB device caused by different mobile phone manufacturers, the accessories returned by the Android mobile phone system taken by the Android application terminal are cached; or, the Usb Access object taken by the Android device is frequently mistakenly reported in the process of calling the standard code, so that the object needs to be opened for many times; or, the USB pull-out state of part of the Android devices returns slowly, and the initialization opportunity can be missed when the Android devices are plugged in and pulled out quickly. The above disadvantages all cause the problem that Android is arranged between the device side and the USB device to have poor stability in data transmission.
Based on the above analysis, an embodiment of the present application provides a method for implementing data transmission, where the method is applied to an Android device side, and after an Android system of the device side starts an AOA mode, a file descriptor is transmitted to a JAVA local interface, and a corresponding handle is obtained, so that a data transmission process can be implemented at a JAVA local interface of a bottom layer through the handle, and two layers, i.e., an input layer and an output layer, are bypassed, thereby avoiding an influence of a bottom operation on an upper layer, and improving stability of data transmission between the device side and a USB device in an access mode.
The method for implementing data transmission provided by the embodiment of the present application will be described in detail below with reference to the accompanying drawings in the embodiment of the present application.
Referring to fig. 1, fig. 1 is a flowchart of a method for implementing data transmission according to an embodiment of the present application, where the method for implementing data transmission includes the following steps:
step S101: after the android system of the equipment end starts the AOA mode, a file descriptor corresponding to the android system is obtained.
Step S102: and transmitting the file descriptor to a JAVA local interface, and acquiring a handle corresponding to the file descriptor.
Step S103: and the handle is utilized to realize data transmission between the device side and the USB device in the JAVA local interface.
In an optional embodiment, after the android system of the device side starts the AOA mode (a detailed description will be given to a mode in which the android system starts the AOA mode in a subsequent embodiment), the device side may obtain a file descriptor (ParcelFileDescriptor file descriptor) corresponding to the android system, where the file descriptor is a JAVA object. As an implementation manner, after the device successfully starts the AOA mode, the android system returns a file descriptor to the device.
Then, the device side may transmit the file descriptor to a JAVA Native Interface (JNI) to perform the subsequent steps. After the file descriptor is transmitted to the JNI, the corresponding handle may be obtained according to the file descriptor.
As an implementation manner, please refer to fig. 2, fig. 2 is a flowchart of a specific implementation manner of step S102 provided in an embodiment of the present application, and the step S102 may include the following steps:
step S201: and acquiring member variables corresponding to the file descriptors.
Step S202: and converting the member variable into a handle corresponding to the file descriptor.
The device side may first obtain a member variable (FileDescriptor) corresponding to the file descriptor in the JNI, and then convert the member variable into a handle (Fd handle) usable by the Linux system. Therefore, the read-write function can be started in the JNI between the device side and the USB device. That is, data transfer between the device side and the USB device can be implemented in the JNI using the handle.
Therefore, after the android system at the device end starts the AOA mode, the file descriptor is transmitted to the JAVA local interface, and the corresponding handle is acquired, so that the data transmission process can be realized at the JAVA local interface at the bottom layer through the handle, and the middle two layers of the input layer and the output layer are avoided, thereby avoiding the influence of the bottom layer operation on the upper layer, and improving the stability of data transmission between the device end and the USB device in the access mode.
According to different requirements, the step S103 has multiple implementation manners, for example: the device side transmits data to the USB device, namely, the data reading function of the device side is realized; or, the USB device transmits data to the device side (the device side receives the data transmitted by the USB device), that is, the data writing function of the device side is realized; or, the interaction between the device side and the USB device, that is, the data read-write function of the device side is realized. The embodiment of step S103 and the implementation time or implementation conditions of each embodiment are not specifically limited in the embodiments of the present application, and those skilled in the art may make appropriate adjustments according to actual situations.
Various implementations of step S103 are described in detail below by way of example.
In the first embodiment, the step S103 may include the following steps:
and transmitting the data selected by the user to the USB equipment corresponding to the handle by using the reading function.
In this embodiment, the device side may use a read function (… …; function in the header file of the unord.h) to implement data transmission between the device side and the USB device at the JAVA local interface of the bottom layer, thereby avoiding the influence of the bottom layer operation on the upper layer and improving the stability of data transmission between the device side and the USB device in the access mode.
After the above steps, the method for implementing data transmission provided in the embodiment of the present application may further include the following steps:
and if the return value of the reading function is larger than zero, determining that the data reading of the equipment terminal is successful.
In the above scheme, if the return value of the read function is greater than zero, it indicates that the device side successfully transmits data to the USB device, and successful data transmission means that the device side and the USB device have already established a connection and can transmit data.
In a second embodiment, the step S103 may include the following steps:
and receiving data transmitted by the USB device corresponding to the handle by using the write-in function.
In this embodiment, the device side may use a write function (… …; function in the header file of the unord.h) to implement data transmission between the device side and the USB device at the JAVA local interface of the bottom layer, thereby avoiding the influence of the bottom layer operation on the upper layer and improving the stability of data transmission between the device side and the USB device in the access mode.
After the above steps, the method for implementing data transmission provided in the embodiment of the present application may further include the following steps:
and if the return value of the write-in function is larger than zero, determining that the data write-in of the equipment terminal is successful.
In the above scheme, if the return value of the write function is greater than zero, it indicates that the device side successfully receives data from the USB device, and successful data reception means that the device side and the USB device have already established a connection and can receive data.
In a third embodiment, the step S103 may include the following steps:
and transmitting the data selected by the user to the USB equipment corresponding to the handle by using the reading function, and receiving the data transmitted by the USB equipment corresponding to the handle by using the writing function.
In this embodiment, the device side can respectively utilize the read function and the write function to realize data transmission between the device side and the USB device at the JAVA local interface of the bottom layer, thereby avoiding the influence of the bottom layer operation on the upper layer and improving the stability of data transmission between the device side and the USB device in the access mode.
After the above steps, the method for implementing data transmission provided in the embodiment of the present application may further include the following steps:
and if the return values of the read function and the write function are both larger than zero, determining that the data reading and writing of the equipment end are successful.
In the above scheme, if the return values of the read function and the write function are both greater than zero, it indicates that data transmission between the device side and the USB device is successful, and successful data transmission means that the device side and the USB device have established connection and can receive and transmit data.
In summary, in the method for implementing data transmission provided in the embodiment of the present application, the corresponding handle may be obtained by obtaining the member variable corresponding to the file descriptor, so that the process of data transmission may be implemented by the handle at the bottom JAVA local interface, and the middle two layers, i.e., the input layer and the output layer, are bypassed, thereby avoiding the influence of the bottom operation on the upper layer, and improving the stability of data transmission between the device side and the USB device in the access mode.
Further, referring to fig. 3, fig. 3 is a flowchart of another method for implementing data transmission according to an embodiment of the present application, where in the method for implementing data transmission, after the step S101, the method may further include the following steps:
step S301: and if an instruction for representing the insertion of the USB equipment is received, initiating AOA mode query to the system.
Step S302: and if an instruction for representing that the user confirms to start the AOA mode is received, starting the AOA mode.
In an optional embodiment, first, Activity to be bound can be found in an android manifest. The android manifest refers to an application list, one must be included in a root directory of each application, and file names must be identical. The file contains the configuration information of the APP, and the android system needs to run the code of the APP according to the content in the APP and display an interface. Activity is an Android application component (also known as one of the four major components of Android) that provides a screen through which a user can interact to perform certain operations, such as placing a phone call, taking a picture, sending an email, or viewing a map.
Then, the device side may create a broadcast receiver in a dynamic registration or static registration manner for receiving some broadcasts from the android system. The broadcast to be received may be of various types, which is not specifically limited in the embodiment of the present application, for example: the broadcast (com. android. example. USB _ policy) of the USB device plug-in and plug-out STATE, the broadcast (android. hardware.use. USB _ STATE) of the USB device usage right, and the like can be monitored.
As an implementation manner, in the method for implementing data transmission provided in the embodiment of the present application, two broadcasts (respectively named broadcast 1 and broadcast 2) may be received, where broadcast 1 is used to monitor the status of USB device insertion and pull-out, and broadcast 2 is used to obtain the usage right of the USB device.
When the android device receives the value true in the broadcast 1 (that is, receives an instruction for representing the insertion of the USB device), it may consider that the USB device is inserted, and therefore the device may initiate the query in the AOA mode. After the device side initiates the AOA mode query, a prompt window can pop up on the display screen to inquire whether the user starts the AOA mode, and if the user confirms that the AOA mode is started, the android system sends a broadcast 2 to the device side. When the device receives the content in broadcast 2, the device confirms that the AOA mode is turned on by the user, and the device can turn on the AOA mode.
In the above scheme, after the USB device is plugged in and the user confirms to open the AOA mode, the device side may open the AOA mode to implement data transmission between the device side and the USB device.
Referring to fig. 4, fig. 4 is a block diagram of an apparatus for implementing data transmission according to an embodiment of the present application, where the apparatus 400 for implementing data transmission may include: a first obtaining module 401, configured to obtain a file descriptor corresponding to an android system after the android system at an equipment end starts an AOA mode; a second obtaining module 402, configured to transmit the file descriptor to a JAVA local interface, and obtain a handle corresponding to the file descriptor; a data transmission module 403, configured to implement data transmission between the device side and the USB device in the JAVA local interface by using the handle.
In the embodiment of the application, after the android system at the device end starts the AOA mode, the file descriptor is transmitted to the JAVA local interface, and the corresponding handle is acquired, so that the data transmission process can be realized at the JAVA local interface at the bottom layer through the handle, and two layers of the middle input layer and output layer are bypassed, thereby avoiding the influence of the bottom layer operation on the upper layer, and improving the stability of data transmission between the device end and the USB device in the access mode.
Further, the data transmission module 403 is further configured to: and transmitting the data selected by the user to the USB equipment corresponding to the handle by using a reading function.
In the embodiment of the application, data transmission between the device side and the USB device can be realized by using the read function at the JAVA local interface of the bottom layer, so that the influence of the bottom layer operation on the upper layer is avoided, and the stability of data transmission between the device side and the USB device in the access mode is improved.
Further, the apparatus 400 for implementing data transmission further includes: and the first determining module is used for determining that the data reading of the equipment terminal is successful if the return value of the reading function is greater than zero.
In this embodiment of the present application, if the return value of the read function is greater than zero, it indicates that the device side successfully transmits data to the USB device.
Further, the data transmission module 403 is further configured to: and receiving the data transmitted by the USB equipment corresponding to the handle by using a write-in function.
In the embodiment of the application, data transmission between the device end and the USB device can be realized by using the write-in function at the JAVA local interface of the bottom layer, so that the influence of the bottom layer operation on the upper layer is avoided, and the stability of data transmission between the device end and the USB device in the access mode is improved.
Further, the apparatus 400 for implementing data transmission further includes: and the second determining module is used for determining that the data writing of the equipment terminal is successful if the return value of the writing function is greater than zero.
In this embodiment, if the return value of the write function is greater than zero, it indicates that the device side successfully receives data from the USB device.
Further, the apparatus 400 for implementing data transmission further includes: and the third determining module is used for determining that the data reading and writing of the equipment terminal are successful if the return values of the read function and the write function are both greater than zero.
In the embodiment of the present application, if the return values of the read function and the write function are both greater than zero, it indicates that data transmission between the device side and the USB device is successful.
Further, the second obtaining module 402 is further configured to: acquiring member variables corresponding to the file descriptors; and converting the member variable into a handle corresponding to the file descriptor.
In the embodiment of the application, the corresponding handle can be obtained by obtaining the member variable corresponding to the file descriptor, so that the data transmission process can be realized through the handle at the bottom JAVA local interface, and the middle two layers, i.e., the input layer and the output layer, are bypassed, thereby avoiding the influence of the bottom operation on the upper layer, and improving the stability of data transmission between the device side and the USB device in the access mode.
Further, the apparatus 400 for implementing data transmission further includes: the query module is used for initiating AOA mode query to the system if receiving an instruction for representing the insertion of the USB equipment; and the starting module is used for starting the AOA mode if receiving an instruction for representing that a user confirms to start the AOA mode.
In this embodiment of the present application, after the USB device is inserted and the user confirms to open the AOA mode, the device side may open the AOA mode, so as to implement data transmission between the device side and the USB device.
Referring to fig. 5, fig. 5 is a block diagram of an electronic device according to an embodiment of the present disclosure, where the electronic device 500 includes: at least one processor 501, at least one communication interface 502, at least one memory 503, and at least one communication bus 504. Wherein, the communication bus 504 is used for realizing direct connection communication of these components, the communication interface 502 is used for communicating signaling or data with other node devices, and the memory 503 stores machine readable instructions executable by the processor 501. When the electronic device 500 is running, the processor 501 communicates with the memory 503 via the communication bus 504, and the machine-readable instructions, when called by the processor 501, perform the above-described method for implementing data transmission.
For example, the processor 501 of the embodiment of the present application may read the computer program from the memory 503 through the communication bus 504 and execute the computer program to implement the following method: step S101: after the android system of the equipment end starts the AOA mode, a file descriptor corresponding to the android system is obtained. Step S102: and transmitting the file descriptor to a JAVA local interface, and acquiring a handle corresponding to the file descriptor. Step S103: and the handle is utilized to realize data transmission between the device side and the USB device in the JAVA local interface.
The processor 501 may be an integrated circuit chip having signal processing capabilities. The Processor 501 may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field-Programmable Gate arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components. Which may implement or perform the various methods, steps, and logic blocks disclosed in the embodiments of the present application. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The Memory 503 may include, but is not limited to, Random Access Memory (RAM), Read Only Memory (ROM), Programmable Read Only Memory (PROM), Erasable Read Only Memory (EPROM), electrically Erasable Read Only Memory (EEPROM), and the like.
It will be appreciated that the configuration shown in FIG. 5 is merely illustrative and that electronic device 500 may include more or fewer components than shown in FIG. 5 or have a different configuration than shown in FIG. 5. The components shown in fig. 5 may be implemented in hardware, software, or a combination thereof. In this embodiment, the electronic device 500 may be, but is not limited to, an entity device such as a desktop, a laptop, a smart phone, an intelligent wearable device, and a vehicle-mounted device, and may also be a virtual device such as a virtual machine. In addition, the electronic device 500 is not necessarily a single device, but may also be a combination of multiple devices, such as a server cluster, and the like. In this embodiment of the application, the device side in the method for implementing data transmission may be implemented by using the electronic device 500 shown in fig. 5.
Embodiments of the present application further provide a computer program product, including a computer program stored on a non-transitory computer readable storage medium, where the computer program includes program instructions, and when the program instructions are executed by a computer, the computer can execute the steps of the method for implementing data transmission in the foregoing embodiments, for example, including: after an AOA mode is started by an android system of an equipment end, a file descriptor corresponding to the android system is obtained; transmitting the file descriptor to a JAVA local interface, and acquiring a handle corresponding to the file descriptor; and realizing data transmission between the equipment terminal and the USB equipment in the JAVA local interface by using the handle.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and there may be other divisions when actually implemented, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some communication interfaces, and may be in an electrical, mechanical or other form.
In addition, units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
Furthermore, the functional modules in the embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
In this document, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions.
The above description is only an example of the present application and is not intended to limit the scope of the present application, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims (10)

1. A method for implementing data transmission, comprising:
after an AOA mode is started by an android system of an equipment end, a file descriptor corresponding to the android system is obtained;
transmitting the file descriptor to a JAVA local interface, and acquiring a handle corresponding to the file descriptor;
and realizing data transmission between the equipment terminal and the USB equipment in the JAVA local interface by using the handle.
2. The method for realizing data transmission according to claim 1, wherein the using the handle to realize data transmission between the device side and the USB device in the JAVA local interface comprises:
and transmitting the data selected by the user to the USB equipment corresponding to the handle by using a reading function.
3. The method according to claim 2, wherein after the transferring the data selected by the user to the USB device corresponding to the handle by using the read function, the method further comprises:
and if the return value of the reading function is larger than zero, determining that the data reading of the equipment terminal is successful.
4. The method for realizing data transmission according to claim 1, wherein the using the handle to realize data transmission between the device side and the USB device in the JAVA local interface comprises:
and receiving the data transmitted by the USB equipment corresponding to the handle by using a write-in function.
5. The method for implementing data transmission according to claim 4, wherein after the receiving, by using the write function, the data transmitted by the USB device corresponding to the handle, the method further includes:
and if the return value of the write-in function is larger than zero, determining that the data write-in of the equipment terminal is successful.
6. The method for realizing data transmission according to claim 1, wherein after the device-side interaction with the USB device is realized in the JAVA local interface by using the handle, the method further comprises:
and if the return values of the read function and the write function are both larger than zero, determining that the data reading and writing of the equipment end are successful.
7. The method for implementing data transmission according to any one of claims 1 to 6, wherein the obtaining the handle corresponding to the file descriptor includes:
acquiring member variables corresponding to the file descriptors;
converting the member variable into a handle corresponding to the file descriptor;
before the obtaining of the file descriptor corresponding to the system, the method further includes:
if an instruction for representing the insertion of the USB equipment is received, initiating AOA mode query to the system;
and if an instruction for representing that a user confirms to open the AOA mode is received, the AOA mode is opened.
8. An apparatus for implementing data transmission, comprising:
the device comprises a first acquisition module, a second acquisition module and a third acquisition module, wherein the first acquisition module is used for acquiring a file descriptor corresponding to an android system after the android system of an equipment end starts an AOA mode;
the second acquisition module is used for transmitting the file descriptor to a JAVA local interface and acquiring a handle corresponding to the file descriptor;
and the data transmission module is used for realizing data transmission between the equipment terminal and the USB equipment in the JAVA local interface by using the handle.
9. An electronic device, comprising: a processor, a memory, and a bus;
the processor and the memory are communicated with each other through the bus;
the memory stores program instructions executable by the processor, the processor invoking the program instructions to perform a method of enabling data transfer as claimed in any one of claims 1-7.
10. A non-transitory computer-readable storage medium storing computer instructions which, when executed by a computer, cause the computer to perform the method of implementing data transfer according to any one of claims 1-7.
CN202011391577.1A 2020-12-01 2020-12-01 Method and device for realizing data transmission Pending CN112463690A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011391577.1A CN112463690A (en) 2020-12-01 2020-12-01 Method and device for realizing data transmission

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011391577.1A CN112463690A (en) 2020-12-01 2020-12-01 Method and device for realizing data transmission

Publications (1)

Publication Number Publication Date
CN112463690A true CN112463690A (en) 2021-03-09

Family

ID=74805272

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011391577.1A Pending CN112463690A (en) 2020-12-01 2020-12-01 Method and device for realizing data transmission

Country Status (1)

Country Link
CN (1) CN112463690A (en)

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100174833A1 (en) * 2009-01-05 2010-07-08 Roderick David Earle Filer Method and Apparatus for Identifying a Device Handle in a Computer System
US20140330992A1 (en) * 2012-03-21 2014-11-06 Huawei Device Co., Ltd. USB Device Communication Method, Device and System
JP2015049600A (en) * 2013-08-30 2015-03-16 Necソリューションイノベータ株式会社 Peripheral equipment controller, peripheral equipment control method and peripheral equipment control program
CN106844275A (en) * 2016-12-30 2017-06-13 百度在线网络技术(北京)有限公司 Data transmission method and device
CN106936869A (en) * 2015-12-30 2017-07-07 沈阳美行科技有限公司 A kind of car interconnection plane method and system based on AOA agreements
US20180060251A1 (en) * 2016-08-29 2018-03-01 Hyundai Motor Company Usb communication control method for usb accessory
US20180267907A1 (en) * 2017-03-15 2018-09-20 Sling Media Pvt Ltd Methods and apparatus for communication between mobile devices and accessory devices
WO2020103680A1 (en) * 2018-11-19 2020-05-28 炬星科技(深圳)有限公司 Data communication method, and human-machine interaction system
CN111371851A (en) * 2020-02-21 2020-07-03 苏州浪潮智能科技有限公司 Connection method, connection device, electronic equipment and storage medium

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100174833A1 (en) * 2009-01-05 2010-07-08 Roderick David Earle Filer Method and Apparatus for Identifying a Device Handle in a Computer System
US20140330992A1 (en) * 2012-03-21 2014-11-06 Huawei Device Co., Ltd. USB Device Communication Method, Device and System
JP2015049600A (en) * 2013-08-30 2015-03-16 Necソリューションイノベータ株式会社 Peripheral equipment controller, peripheral equipment control method and peripheral equipment control program
CN106936869A (en) * 2015-12-30 2017-07-07 沈阳美行科技有限公司 A kind of car interconnection plane method and system based on AOA agreements
US20180060251A1 (en) * 2016-08-29 2018-03-01 Hyundai Motor Company Usb communication control method for usb accessory
CN106844275A (en) * 2016-12-30 2017-06-13 百度在线网络技术(北京)有限公司 Data transmission method and device
US20180267907A1 (en) * 2017-03-15 2018-09-20 Sling Media Pvt Ltd Methods and apparatus for communication between mobile devices and accessory devices
WO2020103680A1 (en) * 2018-11-19 2020-05-28 炬星科技(深圳)有限公司 Data communication method, and human-machine interaction system
CN111371851A (en) * 2020-02-21 2020-07-03 苏州浪潮智能科技有限公司 Connection method, connection device, electronic equipment and storage medium

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
CONOWEN: "Android的NDK开发(5)-Android JNI层实现文件的read、write与seek操作", pages 1 - 9, Retrieved from the Internet <URL:https://blog.csdn.net./conowen/article/details/7525837> *
位恒曦;段晋军;韩晓红;常晓明;: "基于AOA协议实现Android设备的USB通信", 电子技术应用, vol. 39, no. 09, 6 September 2013 (2013-09-06), pages 31 - 37 *

Similar Documents

Publication Publication Date Title
US10380050B2 (en) Electronic device configured to communicate with an external electronic device using a USB connector
CN109902053B (en) SPI communication method based on double controllers, terminal equipment and storage medium
CN111314799A (en) Terminal system architecture, communication system, communication method, and storage medium
CN108664429B (en) Master-slave configuration communication protocol, method for improving compatibility and electronic equipment
CN110377369B (en) Method, device and computer storage medium for running small program
CN108287804B (en) I2C controller driving method and system
US9948732B2 (en) Method for providing status messaging service in electronic device and the electronic device thereof
CN108933968B (en) Message format conversion method and device, storage medium and android terminal
US20190107929A1 (en) Method and device for loading content of page, and electronic device
CN112559425A (en) PCIE port splitting method, device, equipment and medium
KR20200042798A (en) Method for controlling the execution of different operating systems, electronic device and storage medium therefor
CN113853754A (en) In the bluetoothTMElectronic device and method for displaying external electronic device query list in network environment
US20120144084A1 (en) Data management device and method thereof
CN112463690A (en) Method and device for realizing data transmission
CN112003928B (en) Multifunctional screen synchronous control method, device and equipment
CN108563492B (en) Data acquisition method, virtual machine and electronic equipment
CN111726848B (en) Equipment binding method, target starting device, fixed terminal and storage medium
CN114327647A (en) Server startup method, system, equipment and computer readable storage medium
CN110109707B (en) Terminal starting method and device and terminal
CN112651212A (en) Method and terminal for remotely acquiring word stock
CN112818336A (en) Data access method, data access device and computer readable storage medium
CN111488207A (en) Application process keep-alive method, device, network equipment and storage medium
CN105867954B (en) system data updating method, electronic equipment and system
CN112887389B (en) Version-based equipment interoperation method, system, device and storage medium
CN115309415B (en) Application software installation method, device and system and electronic equipment

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