(Original)-smart energy meter SM1 algorithm development kit (main station interface) Basics

Source: Internet
Author: User

The new State Grid standard has been launched. Recently, some materials have just been obtained. Because the company does not have a R & D team, and the DLL provided by the State Grid does not have a demo, many things have to be tested by themselves;

Some people just got in touch with this thing and don't know where to start.

I caught a cold today and have no thoughts to write.Program, Close-upArticleI hope it will be helpful to everyone. At the same time, I hope everyone can come and communicate with each other;

-------------------------------- Long Yi

I am writing a remote fee control smart electric meter, so I only need to use the following two functions (other functions have not been tested yet, but I heard that the return value of the "recharge function" is inconsistent with the description)

Main Station Function Description
(The following functions in testzhuzhan. dll, please read in the RD-1000 test)
Plug in the card to test the parent card.
1. Identity Authentication Functions
Function Name identityauthentication (char * Div, char * randandendata)
Function Identity Authentication random number and ciphertext
Div, input parameter, 8-byte dispersion factor, hexadecimal string.
Parameter description randandendata, output parameter, bytes type, 8-byte Random Number + 8 bytes
Ciphertext.
Success indicates 0. Success;
200. Failed to connect to the encryptor;
201. An error occurred while obtaining random number 1;
202. An error occurred while obtaining random number 2;
203. Key dispersion failed;
204. Data Encryption failed;
205. failed to retrieve the ciphertext;
2. Remote Control Functions
Function Name usercontrol (char * randdivesamnumdata, char * dataout)
Function remote control
Randdivesamnumdata, input parameter, random type, 4-byte Random Number
Parameter description + 8-byte dispersion factor + 8-byte Esam serial number + Data plaintext.
Dataout, ciphertext, 20-byte ciphertext
Success indicates 0. Success;
200. Failed to connect to the encryptor;
201. failed to write the card;
202. card reading failed;
203. ciphertext calculation failed;

Note: This dll cannot be directly referenced in C # and VB. You need to use dllimport to reference it.

Communication Process:

We can see that the design process is:

1. Take the 8-byte dispersion factor, a hexadecimal string (you can set a fixed 8-byte number );

 

 

2. Call the identityauthentication function on the testzhuzhan. DLL interface to obtain the random number 1 and ciphertext 1;

3. Send the obtained random number 1 and ciphertext 1 to the electric meter, and the electric meter returns the 4-byte random number 2 and 8-byte Esam serial number;

4. Call the security authentication function usercontrol (char * randdivesamnumdata, char * dataout) of the testzhuzhan. DLL interface to obtain the 20-byte ciphertext;

In parameter 1: The data plaintext is: 1 byte control code N1 + 1 byte reserved field + date later than the current time yymmddhhmmss (the book writes ssmmhhddmmyy refers to the ciphertext, plain text does not need to be reversed. I have been debugging for a long time here );

N1 = 1ah indicates a trip, n1 = 1bh indicates that the switch is allowed, n1 = 2ah indicates an alarm, n1 = 2bh indicates that the alarm is cleared, n1 = 3ah indicates power saving, n1 = 3bh indicates power saving.

5. Send the ciphertext to the electric meter.

Note: Only one security authentication is required for Step 1 and step 3,

The control is mainly implemented in step 4 and Step 5.

OperationsCodeI will discuss with you in the next article. ---- long Yi)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.