Summary of the invention
The invention provides a kind of Weighing system communication method based on digital sensor, do not influencing under the situation of making and using, after raw data encrypted and decipher, realize instrument and the mutual communication of pairing digital sensor, the safe reliability of assurance weight data transmission channels.
The present invention is that the technical scheme that achieves the above object is: a kind of Weighing system communication method based on digital sensor is characterized in that:
(1), generates the dispatch from the factory key and the password that dispatches from the factory according to weighing system digital sensor coded message and random code, foundation has the digital sensor key file of dispatch from the factory key and digital sensor coded message, and digital sensor is stored dispatch from the factory password, digital sensor coded message and digital sensor key file;
(2), the system key that generated by the automatic unpaired message of instrument of instrument stores meter timing signal and the system password of input arbitrarily, system key and system password are downloaded in each digital sensor, and instrument storage is fetched separately the dispatch from the factory key and the password that dispatches from the factory from each digital sensor;
(3), instrument sends communication command to the target number sensor, takes out corresponding digital sensor key file according to the coded message of target number sensor in instrument, generates the digital sensor cryptogram after inverse operation; The data stream of digital sensor cryptogram and communication command and system password Hybrid Encryption generation system encrypted packets, transmitting system encrypted packets and sensor of interest coded message, target number sensor monitors, receiving system encrypted packets, with system key and the secret key decryption of dispatching from the factory reduction acquisition system raw data packets, system's raw data packets amalgamation is treated as system's raw data as communication command;
(4), the target number sensor is connected news and is received order, to the weight data sampling, the weight data that obtains is broken into the weight data bag, weight data bag and this digital sensor coded message, dispatch from the factory password and system password mix and generate the encrypted packets of dispatching from the factory, transmission dispatch from the factory encrypted packets and target instrument address, the target instrument monitoring, receive the encrypted packets of dispatching from the factory, with obtaining to dispatch from the factory raw data packets after the system key and the secret key decryption of dispatching from the factory, the raw data packets of will dispatching from the factory amalgamation is processed into the data of weighing, and finishes instrument and weight data transmission communication in the weighing system.
Wherein:
Described system encryption packet is by the digital sensor cryptogram and system password makes up or by obtaining combinatioin code after the computing, the data stream Hybrid Encryption with communication command generates again; After target number sensor monitors, the receiving system encrypted packets, the compound secret key decryption system encryption packet reduction acquisition system raw data packets that obtains with the system key and the key computing of dispatching from the factory, and the key that dispatches from the factory is to take out corresponding digital sensor key file to obtain from system encryption packet internal object digital sensor address.
Described system encryption packet is generated with the system password Hybrid Encryption by the data stream Hybrid Encryption generation encrypted packets of digital sensor cryptogram and communication command again; After target number sensor monitors, the receiving system encrypted packets, obtain encrypted packets with system key deciphering reduction earlier, again with the secret key decryption reduction acquisition system raw data packets of dispatching from the factory, and the key that dispatches from the factory is to take out corresponding digital sensor key file to obtain from system encryption packet internal object digital sensor address.
The described ciphertext data bag that dispatches from the factory generates encrypted packets by weight data bag and digital sensor coded message and the password Hybrid Encryption of dispatching from the factory, and mixes generation again with system password; The target instrument monitoring, receive the encrypted packets of dispatching from the factory, obtain encrypted packets with system key deciphering reduction, take out corresponding digital sensor key file according to the target number sensor address, with obtaining to dispatch from the factory raw data packets after the secret key decryption of dispatching from the factory, the raw data packets of will dispatching from the factory amalgamation is processed into the data of weighing, and finishes instrument and weight data transmission communication in the weighing system.
The described ciphertext data bag that dispatches from the factory generates encrypted packets by weight data bag and digital sensor coded message and the password Hybrid Encryption of dispatching from the factory, and mixes generation again with system password; The target instrument monitoring, receive the encrypted packets of dispatching from the factory, obtain encrypted packets with system key deciphering reduction, take out corresponding digital sensor key file according to the target number sensor address, with obtaining to dispatch from the factory raw data packets after the secret key decryption of dispatching from the factory, the raw data packets of will dispatching from the factory amalgamation is processed into the data of weighing, and finishes instrument and weight data transmission communication in the weighing system.
Above-mentioned digital sensor and instrument can be passed through data bus or wireless channel communication.
Above-mentioned digital sensor coded message is digital sensor sequence number or the digital sensor factory number or the digital sensor date of production or is installed in circuit board sequence number on the digital sensor.
The present invention utilizes weighing system at manufacture process and automatic dispatch from the factory key and the system key that generates of assembling and setting process, and dispatch from the factory password and system password are set respectively from digital sensor end and instrument end, therefore the communication between instrument and the digital sensor must rely on cooperatively interacting between manufacturing plant and the user, respectively the raw data of instrument and digital sensor is encrypted by the system password and the password that dispatches from the factory, be decrypted by dispatch from the factory key and system key again, realize the communication between instrument and the corresponding digital sensor, stopped either party inaccuracy, guaranteed the accurate reliability of crucial continuous data because of password leakage or the cheating data of weighing that cause.The present invention is because irrelevant with communication interface and communication media, and the third party device of therefore also avoiding inserting weighing system is practised fraud by forging continuous data, is not influencing under the situation of making and using, and can guarantee the level security of weighing system digital communication.
Embodiment
The present invention is based on the Weighing system communication method of digital sensor, is to carry out by the following method,
(1), according to the coded message of the digital sensor of weighing system, as date of production of the factory number of digital sensor sequence number, digital sensor, digital sensor, be installed in settings such as PC plate sequence number on the digital sensor key that dispatches from the factory, and the password that dispatches from the factory is the random code of producing, foundation has the digital sensor key file of dispatch from the factory key and digital sensor coded message, and digital sensor is stored dispatch from the factory password, digital sensor coded message and digital sensor key file;
(2), the system key and the system password that are generated by the automatic unpaired message of instrument of instrument stores meter timing signal, and being the user, system password is provided with arbitrarily at the instrument end, system key and system password are stored in the instrument, and system key and system password downloaded to each digital sensor stored, instrument is fetched separately dispatch from the factory key and dispatch from the factory password and storage from each digital sensor simultaneously.
(3), instrument sends communication command to the target number sensor, takes out corresponding digital sensor key file according to the coded message of target number sensor in instrument, generates the digital sensor cryptogram after inverse operation; The data stream of digital sensor cryptogram and communication command and system password Hybrid Encryption generation system ciphertext data bag, transmitting system ciphertext data bag and sensor of interest coded message, target number sensor monitors, receiving system encrypted packets, with system key and the secret key decryption of dispatching from the factory reduction acquisition system raw data packets, system's raw data packets amalgamation is treated as system's raw data as communication command.
(4), the target number sensor is connected news and is received order, to the weight data sampling, the weight data that obtains is broken into the weight data bag, weight data bag and this digital sensor coded message, dispatch from the factory password and system password mix to generate and add the ciphertext data bag that dispatches from the factory, transmission dispatch from the factory encrypted packets and target instrument address, the target instrument monitoring, receive the encrypted packets of dispatching from the factory, with obtaining to dispatch from the factory raw data packets after the system key and the secret key decryption of dispatching from the factory, the raw data packets of will dispatching from the factory amalgamation is processed into the data of weighing, and finishes instrument and weight data transmission communication in the weighing system.
In above-mentioned encryption and decrypting process, adopt symmetric cryptographic algorithms such as some XOR, DES, 3DES or AES, also can adopt the RSA asymmetric cryptographic algorithm.
Embodiment 1
Weigh for digital automobile, weighing system comprises one of digital instrument, digital sensor and scale body, digital sensor is connected with digital instrument by the CAN bus, between instrument and the digital sensor by the form swap data of certain communication protocol with the CAN Frame.
(1), manufacturing plant sets up the digital sensor key file to each digital sensor, the digital sensor key file contains the binary code of one group of 12 byte, be to produce by 12 bit digital sensor sequence number and one group of 12 random code computing, this random code is the password that dispatches from the factory, and for example the digital sensor sequence number is: UAFD12345678, and random code is 987654321012, then UAFD12345678 converts ASCII character to and is expressed as: 0x35,0x21,0x26,0x24,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18; Random code converts ASCII character to and is expressed as: 0x19,0x18,0x17,0x16,0x15,0x14,0x13,0x12,0x11,0x10,0x11,0x12; Two groups of data through 16 ary codes that an XOR obtains are: 0x2c, 0x39,0x31,0x32,0x04,0x06,0x00,0x06,0x04,0x06,0x00,0x0a, these group data that manufacturing plant obtains are the key that dispatches from the factory, therefore the digital sensor key file has comprised dispatch from the factory key and digital sensor sequence number, and digital sensor key file, dispatch from the factory password and the key that dispatches from the factory are write the storer in several digital sensors, installs and uses for weighing system.The present invention can be with the Alternative digital sensor sequence number in the date of production of factory number that adopts digital sensor or digital sensor.
(2); when digital sensor and instrument be installed to form a truck scale together after; the attendant can import one group of 12 byte arbitrarily as system password in instrument; as: 0x11,0x11,0x11; 0x11; 0x22,0x22,0x22; 0x22; 0x33,0x33,0x33; 0x33; and when meter calibration, instrument match automatically the information that automatically produces existed in the instrument as system key, instrument is issued to system key each digital sensor in the storage system password; and deposit in the storer of digital sensor, the key that dispatches from the factory that the while instrument is fetched each digital sensor is kept in the power down protection storer of instrument with the password that dispatches from the factory.
(3), when weighing system is started working, see shown in Figure 1, power on the beginning after, instrument is to the communication command that sends of digital sensor, this communication command is the data stream that is resolved into fixed byte length by raw data packets, in instrument, take out corresponding digital sensor key file according to target number sensor coded message, after inverse operation, generate the digital sensor cryptogram.Digital sensor cryptogram and system password can obtain combinatioin code by the combination exclusive disjunction, with the combinatioin code of acquisition and the data stream Hybrid Encryption generation system encrypted packets of communication command, and add that the sensor of interest coded message is sent on the data bus.Each digital sensor is the Monitoring Data bus at any time, and inquiry target number sensor number wherein, issue oneself in this way, extraction system encrypted packets then, this target number sensor obtains compound secret key decryption system encryption packet reduction acquisition system raw data packets with the local system key of storage and the key that dispatches from the factory, and the key that dispatches from the factory is to take out corresponding digital sensor key file to obtain from system encryption packet internal object digital sensor address.
(4) and after the target number sensor receives order, see shown in Figure 2ly, carry out sampling operation, begin the weight data of weighing system is sampled, the weight data that obtains is broken into the weight data bag.This digital sensing obtains combinatioin code after according to digital sensor coded message, dispatch from the factory password and system password computing simultaneously, mixes with the weight data bag to generate the encrypted packets of dispatching from the factory again, and adds that target instrument address sends on the data bus.Instrument is the Monitoring Data bus at any time, finds that destination address is to issue the encrypted packets of dispatching from the factory of oneself, receives the encrypted packets of dispatching from the factory.According to the target number sensor address key that dispatches from the factory, obtain compound key with the system key computing, again with compound secret key decryption dispatch from the factory encrypted packets reduction obtain the raw data packets of dispatching from the factory, the raw data packets of will dispatching from the factory amalgamation is processed into the data of weighing, finish instrument and weight data transmission communication in the weighing system, submit to then and do to show or print processing.
Can realize communication between instrument and the corresponding digital sensor by encryption and decryption.
Embodiment 2
The same digital automobile weighing apparatus that adopts, weighing system comprises one of digital instrument, digital sensor and scale body, digital sensor is connected with digital instrument by the CAN bus, between instrument and the digital sensor by the form swap data of certain communication protocol with the CAN Frame.
(1), manufacturing plant sets up the digital sensor key file to each digital sensor, the digital sensor key file contains the binary code of one group of 12 byte, be to produce by 12 bit digital sensor sequence number and one group of 12 random code computing, this random code is the password that dispatches from the factory, and for example the digital sensor sequence number is: UAFD12345678, and random code is 987654321012, then UAFD12345678 converts ASCII character to and is expressed as: 0x35,0x21,0x26,0x24,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18; Random code converts ASCII character to and is expressed as: 0x19,0x18,0x17,0x16,0x15,0x14,0x13,0x12,0x11,0x10,0x11,0x12; Two groups of data through 16 ary codes that an XOR obtains are: 0x2c, 0x39,0x31,0x32,0x04,0x06,0x00,0x06,0x04,0x06,0x00,0x0a, these group data that manufacturing plant obtains are the key that dispatches from the factory, therefore the digital sensor key file has comprised dispatch from the factory key and digital sensor sequence number, and digital sensor key file, dispatch from the factory password and the key that dispatches from the factory are write the storer in several digital sensors, installs and uses for weighing system.The present invention can be with the Alternative digital sensor sequence number in the date of production of factory number that adopts digital sensor or digital sensor.
(2); when digital sensor and instrument be installed to form a truck scale together after; the attendant can import one group of 12 byte arbitrarily as system password in instrument; as: 0x11,0x11,0x11; 0x11; 0x22,0x22,0x22; 0x22; 0x33,0x33,0x33; 0x33; and when meter calibration, instrument match automatically the information that automatically produces existed in the instrument as system key, instrument is issued to system key each digital sensor in the storage system password; and deposit in the storer of digital sensor, the key that dispatches from the factory that the while instrument is fetched each digital sensor is kept in the power down protection storer of instrument with the password that dispatches from the factory.
(3), when weighing system is started working, power on the beginning after, instrument is to the communication command that sends of digital sensor, this communication command is the data stream that is resolved into fixed byte length by raw data packets, in instrument, take out corresponding digital sensor key file according to target number sensor coded message, after inverse operation, generate the digital sensor cryptogram.The data stream Hybrid Encryption of digital sensor cryptogram and communication command generates encrypted packets, is sent on the data bus with system password Hybrid Encryption generation system encrypted packets and with the sensor of interest coded message again.Each digital sensor is at any time on the Monitoring Data bus, and inquiry target number sensor number wherein, issue oneself in this way, extraction system encrypted packets then, the target number sensor obtains encrypted packets with the local system key deciphering of storage, this encrypted packets is taken out corresponding sensor key file according to the target number sensor address, with obtaining system's raw data packets after the secret key decryption of dispatching from the factory, system's raw data packets amalgamation is treated as system's raw data as communication command again.
(4), after the target number sensor receives order, carry out sampling operation, begin the weight data of weighing system is sampled, the weight data that obtains is broken into the weight data bag, weight data bag and this digital sensor coded message and the password Hybrid Encryption of dispatching from the factory generate encrypted packets, mix generating the encrypted packets of dispatching from the factory again with system password, the encrypted packets of dispatching from the factory and target instrument address send on the data bus.Instrument is the Monitoring Data bus at any time, find that destination address is to issue the encrypted packets of dispatching from the factory of oneself, the reception encrypted packets of dispatching from the factory, obtain encrypted packets with system key deciphering reduction, take out corresponding digital sensor key file according to the target number sensor address in the encrypted packets again, with obtaining to dispatch from the factory raw data packets after the secret key decryption of dispatching from the factory, the raw data packets of will dispatching from the factory amalgamation is processed into the data of weighing, finish instrument and weight data transmission communication in the weighing system, submit job shows or print processing then.
Can realize the communication between instrument and the corresponding digital sensor by superencipher and deciphering equally.
Embodiment 3
For the wireless electron hang hook steelyard, have wireless sending and receiving and receive digital sensor module, the scale body of function and have the instrument that function is received in wireless sending and receiving.Because number set up the relation of communication one to one between the wireless telecommunications plate of wireless steelyard and wireless sensor module, so in the application's data communication, do not need to introduce in addition the communication identifier by frequency range and wireless identification.
(1), the binary code that digital sensor key file that sensor generates contains one group of 6 byte is counted for each by manufacturing plant, by 6 circuit board sequence numbers is that A/D plate sequence number and one group of 6 random code computing produce, wherein random code is with being the password that dispatches from the factory, for example A/D plate sequence number is: 234567, and random code is 123987.234567 convert ASCII character to is expressed as: 0x12,0x13,0x14,0x15,0x16,0x17.Random code converts ASCII character to and is expressed as: 0x11,0x12,0x13,0x19,0x18,0x17.Two groups of data through 16 ary codes that an XOR obtains are: 0x03,0x01,0x07,0x0c, 0x0e, 0x00.These group data that manufacturing plant obtains after calculating are the key that dispatches from the factory, weighing system generates a digital sensor key literary composition with above data and installs and uses for system, digital sensor key file, dispatch from the factory password and the key that dispatches from the factory are write the storer on the A/D plate in this digital sensor, install and use for weighing system.
(2), when the assembled uniting and adjustment of instrument of digital sensor and steelyard, peace mediator person can import the system password of one group of 6 byte arbitrarily in instrument, as: 0xaa, 0x13,0x57,0x35,0x25,0x22, and when meter calibration, the instrument of wireless steelyard match automatically the information that automatically produces existed in the instrument as system key, instrument sends to corresponding digital sensor module with system password by wireless transmitter in the storage system password, and deposits in the storer on the A/D plate wherein.Simultaneously, also will dispatch from the factory key and the password that dispatches from the factory of corresponding digital sensor sends to instrument by wireless mode, and this dispatch from the factory key and the password that dispatches from the factory will be stored in the power down protection storer of instrument.
(3), when steelyard works on power, see shown in Figure 3, the communication command that mails to digital sensor from instrument is to resolve into the fixed byte data package length with raw data to form, in instrument, take out corresponding digital sensor key file according to target number sensor coded message, after inverse operation, generate the digital sensor cryptogram, the packet Hybrid Encryption of digital sensor cryptogram and communication command generates encrypted packets, generate the encryption system encrypted packets with the system password Hybrid Encryption again, be converted to signal then and launch.The target number sensor is monitored the wireless signal on this channel at any time, after obtaining wireless data packet, be converted to the encrypted packets of dispatching from the factory, this target number sensor obtains encrypted packets with being stored in local system key deciphering, this encrypted packets is taken out corresponding digital sensor key file according to the target number sensor address again, with obtaining system's raw data packets after the secret key decryption of dispatching from the factory, system's raw data packets amalgamation is treated as system's raw data as communication command again.
(4), after the target number sensor receives order, see shown in Figure 4, carry out sampling operation, begin the weight data of weighing system is sampled, the weight data that obtains is broken into the weight data bag, generate encrypted packets with this digital sensor coded message and the password Hybrid Encryption of dispatching from the factory, mix with system password again and produce the encrypted packets of dispatching from the factory, penetrating plate by wireless receiving and dispatching converts emission of radio frequency signals to and goes out, instrument is received RF signal then, and convert the encrypted packets of dispatching from the factory to, obtain encrypted packets with system key deciphering reduction, take out corresponding digital sensor key file according to the target number sensor address in this encrypted packets again, again with obtaining to dispatch from the factory raw data packets after the secret key decryption of dispatching from the factory, the raw data packets of will dispatching from the factory amalgamation is processed into the data of weighing, and finishes instrument and weight data transmission communication in the weighing system, weight data is submitted to done to show or print processing then.