A Probe into the Software of Express Delivery Cabinet and Storage Cabinet under Windows

Recently, someone asked about the development of express cabinet software. Just think about it when you have nothing to do. First understand the composition of the electronic part of the express cabinet.
A Probe into the Software of Express Delivery Cabinet and Storage Cabinet under Windows

The simple function of the hardware is that the main control computer interacts with the outside through the display touch screen, captures and records images through monitoring, communicates with the server through the network module, and unlocks and detects the lock switch status through the lock control panel.
 

Now it is mainly the software of the master computer, which can run windows or other operating systems for the industrial motherboard.
The main functions of the software are as follows:
1. User port
1. Express delivery 2. Express pickup 3. Personal center

Two, courier port
1, express storage 2, express pickup

Third, the management port
 
  does not look complicated. However, the lock control board of the hardware part has not been used before. I searched on the e-commerce platform and found that some manufacturers sell it. After reading the introduction, commands are basically sent through the serial port, and the lock control board is unlocked or inquired about the opening and closing of the lock. Some commands are sent to the lock control board through the network port, but the form is similar. The price of the network port is higher.

 
Let's study the driver programming of this lock control board.
  The serial port is used to send and receive data. It was done a few years ago and collected data from an instrument to the computer. I remember that it was developed with Vb at that time, the interface was very well designed, and the serial communication used a control mscomm. Just set the parameters, open the serial port, you can send and receive data, analyze the data according to the protocol, and close the serial port when not in use. Serial communication has not been used in MFC. First look at the lock control panel. After comparison, this kind of lock control board was selected.
A Probe into the Software of Express Delivery Cabinet and Storage Cabinet under Windows
The models are fairly complete, including 8, 12, 16, 20, and 24 doors. A treasure link https://item.taobao.com/item.htm?id=581917013199
 
unlocks and queries the lock status through serial communication. I searched the Internet about VS serial communication articles. There are also many methods, such as communicating through ActiveX controls, and calling Windows API function package classes to operate. The method of calling the Windows API function package class is more flexible, and it is more convenient to combine other people's codes on the Internet. Let's look at the command form of the lock control board, which can be simplified to send a string of hexadecimal data, the format is as follows
A Probe into the Software of Express Delivery Cabinet and Storage Cabinet under Windows

  The address of the lock control board mentioned here is generally 1. In the case of multiple blocks, the hardware can be set to other values ​​2, 3, etc. through the DIP switch. Filling in N here is to send instructions to the circuit board whose hardware is set to N. The lock number is the channel number locked on the lock control board. Fill in M ​​to open the M lock, and the last two bytes of the data are checksums. In this way, it is clear that the different boards are distinguished by the "lock control board address", and then the different locks connected to the lock board are distinguished by the "lock number". In this case, if it is a 60-door cabinet, using 5 12-door lock control boards, it is easy to send instructions. First determine the number of the board connected to the door lock, then fix the number on the board connected to the lock, and fill in the data above In the data frame of the format, the check data is updated after the check is calculated and sent out through the serial port, and the corresponding door is opened.

 
 
Use VS2010 MFC programming, using the button control group method, the view is as follows
A Probe into the Software of Express Delivery Cabinet and Storage Cabinet under Windows

 
code show as below

void CrockdemoDlg::OnButton(UINT   nID)
{
    DWORD rtlen;
    BOOL fright=TRUE;
    UINT CrcCheck,temp1;
    BYTE rbuf[100]={0};
    BYTE sbuf[] = {0xAA,0x01,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x0A};
    if(f_common)
    {
        UpdateData(TRUE);
        sbuf[1]=setadd;//锁控板的地址
        sbuf[3]=nID-IDC_BUTTON1+1; //开锁控板的第几个锁
        CrcCheck=Crc16(sbuf,7);
        sbuf[7]=BYTE(CrcCheck%256);
        sbuf[8]=BYTE(CrcCheck/256);
        serial.SendData(sbuf,9);
    }
    else
    {   
    MessageBox(_T("数据接收错误,请检查线有没连接好"),_T("提示"), MB_OK); 
    }

}

After testing, it can be unlocked smoothly. After the above experiment, the driver of the control panel has been unlocked, and the whole software development is more familiar.
 
About serial communication, there are some good information on the Internet, you can refer to the following

Simple example of Windows serial communication
https://blog.csdn.net/horizons_kong/article/details/54412339

VC++ realizes serial communication application program design
https://blog.csdn.net/crjmail/article/details/91043991

  

Well, I will write here today.

Guess you like

Origin blog.51cto.com/14612907/2547370