The content of the invention
The method and its communication system to be communicated it is a primary object of the present invention to provide a kind of with equipment under test, it is intended to reduceThe transit working of PC ends and measured device during test job, realize that free drive is transferred.
To achieve the above object, the present invention provides a kind of method to be communicated with equipment under test, comprises the following steps:
External transducer equipment is searched in detection in predetermined period;
Obtain the facility information of the converter found;
Mode of operation is selected according to the facility information, and data message is sent to converter under the mode of operation selected;
The converter receives the data message, and believes that content carries out read/write operation to equipment under test according to the data.
Preferably, external transducer equipment is searched in the detection in predetermined period also includes:
In predetermined period, the detection of PC ends has searched whether that external transducer equipment accesses, if so, then obtaining the converter of accessFacility information, such as without external equipment access, then into next cycle continue detection search.
Preferably, the predetermined period is 1s.
Preferably, it is described that mode of operation is selected according to the facility information, and data letter is sent under the mode of operation selectedBreath also includes to converter:
PC ends select corresponding mode of operation according to the connecter type of the equipment under test of access.
Preferably, the mode of operation includes I2C patterns and SPI mode.
Preferably, the converter receives the data message, and believes that content carries out read/write to equipment under test according to the dataOperation also includes:
The converter is initialized, the data message sent by the PC ends and parsing are received, according to the data message after parsingContent carries out read/write operation to equipment under test.
The present invention also provides a kind of communication system, and the system includes:
PC ends, for the detection lookup external transducer equipment in predetermined period;
The PC ends include:For the acquisition module for the facility information for obtaining the converter found;For according toFacility information selects the selecting module of mode of operation;For sending data message under the mode of operation selected to converterSending module;
Converter, the PC ends and equipment under test are connected, believe content pair for receiving the data message, and according to the dataEquipment under test carries out read/write operation;
Equipment under test, is connected to the converter, receiving converter data or sends data to converter.
Preferably, the interface type of the equipment under test is I2C interface or SPI interface.
Preferably, the converter also includes being used to receive the data message sent by the PC ends and the parsing module of parsing,And for the communication module of read/write operation to be carried out to equipment under test according to the data information content after parsing.
Technical scheme in predetermined period by detecting external transducer equipment, and according to the converter foundFacility information sets mode of operation, sends data message to carry out the operation read or write to equipment under test so that tested to setIt is standby to be communicated to connect by converter and PC ends, while without installing driver on PC ends, realize and really insert i.e.With.
Embodiment
It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, it is not intended to limit the present invention.
The present invention is further described below in conjunction with the accompanying drawings.
A kind of method to be communicated with equipment under test, as shown in figure 1, comprising the following steps:
External transducer equipment is searched in detection in predetermined period;Obtain the facility information of the converter found;According toThe facility information selects mode of operation, and sends data message to converter under the mode of operation selected;The conversionDevice receives the data message, and believes that content carries out read/write operation to equipment under test according to the data.
Set by detecting external transducer equipment in predetermined period, and according to the facility information of the converter foundMode of operation, data message is sent to carry out the operation read or write to equipment under test so that equipment under test can be by turningParallel operation and PC ends(That is host computer)Communication connection, while without installing driver on PC ends, realize real plug and play.
Preferably, external transducer equipment is searched in the detection in predetermined period also includes:
In predetermined period, the detection of PC ends has searched whether that external transducer equipment accesses, if so, then obtaining the converter of accessFacility information, such as without external equipment access, then into next cycle continue detection search.
Converter is connected by USB interface with PC ends, and PC ends by searching HID automatically(Human InterfaceDevice, human-computer interaction device), i.e. the Vendor ID of converter connection(Vendor code)、Product ID(Product identificationCode)、Version Number(Version number), and an effective handle is obtained to establish the communication port with converter.
In a particular embodiment, the predetermined period is 1s.PC ends are searched and connect HID device automatically, meanwhile, with 1 secondHID device connection state is updated for compartment of terrain.
Preferably, it is described that mode of operation is selected according to the facility information, and data letter is sent under the mode of operation selectedBreath also includes to converter:
PC ends select corresponding mode of operation according to the connecter type of the equipment under test of access.Specifically, equipment under test is bandThe chip or sensor assembly of I2C interface or SPI interface.
Specifically, when connecting multiple converters on same PC ends, different converters is respectively configured differentVendor ID, Product ID, Version Number avoid conflicting, and integrated simulation I2C interface and simulation SPI interface, makeBoth interfaces realize multiplexing.
In a particular embodiment, the mode of operation includes I2C patterns and SPI mode.When equipment under test band is that band I2C connectsWhen the chip or sensor assembly of mouth, PC ends selection mode of operation is I2C patterns;When equipment under test for SPI interface chip orDuring sensor assembly, PC ends selection mode of operation is SPI mode.
Preferably, the converter receives the data message, and believes that content carries out read/write to equipment under test according to the dataOperation also includes:
The converter is initialized, the data message sent by the PC ends and parsing are received, according to the data message after parsingContent carries out read/write operation to equipment under test.
In a particular embodiment, equipment under test message length is set as 64 bytes, and converter receives PC ends or testedAfter the data message that module is sent, then tested module or PC ends be sent to I2C mode standards or SPI mode standard.
Specifically, as shown in Fig. 2 being using the idiographic flow that PC ends are tested equipment under test in this method:
A. PC ends global variable, api function(Application Programming Interface, application programming interfaces letterNumber)Statement and initialization;
B. PC ends start 1S timers, and HID device is searched in timing;A series of api functions are called to be set to position searched HIDIt is standby, True is returned when detecting HID device, otherwise returns to False;
C. if detecting HID device, API Function obtains facility information and effective handle, establishes logical with HID deviceBelieve passage;
D. wait user to select I2C patterns or SPI mode, different operating interface is entered after model selection;
E. wait user to input and send data and read-write length, send data format:First code+command code+write length+reading length+Data to be written, first code 0XAA represent I2C patterns, and first code 0XBB represents SPI mode, and command code 0X01 represents write operation, operationCode 0X02 represents read operation;
F. under I2C patterns, if writing length>2 data messages for representing that PC ends are sent represent write operation(Call API lettersNumber sends data to converter), otherwise represent read operation(I.e. PC ends API Function first sends data message to converter, treatsThe data of equipment under test transmission are read after converter processing again).
The present invention also provides a kind of communication system, as shown in figure 3, the system includes:
PC ends 1, for the detection lookup external transducer equipment in predetermined period;
The PC ends 1 include:For the acquisition module 11 for the facility information for obtaining the converter 2 found;For according toFacility information selects the selecting module 12 of mode of operation;For sending data message under the mode of operation selected to converter2 sending module 13;
Converter 2, the PC ends 1 and equipment under test 3 are connected, for receiving the data message, and according in data letterHold and read/write operation is carried out to equipment under test 3;
Equipment under test 3, is connected to the converter 2, the data of receiving converter 2 or sends data to converter 2.
Preferably, the interface type of the equipment under test 3 is I2C interface or SPI interface.
Preferably, the converter 2 also includes being used to receive the data message sent by the PC ends 1 and the parsing of parsingModule 21, and for carrying out the communication module 22 of read/write operation to equipment under test 3 according to the data information content after parsing.
It should be appreciated that it these are only the preferred embodiments of the present invention, it is impossible to therefore the scope of the claims of the limitation present invention,Every equivalent structure made using description of the invention and accompanying drawing content or equivalent flow conversion, or directly or indirectly useIn other related technical areas, it is included within the scope of the present invention.