RFID card photography. If it is a traditional development, we generally need to first know what type of RFID card reader is, and write a set of read/write RFID code to read RFID tags. This is also true for camera driver development. First, you need to know the camera driver protocol, and then write the code to read the image and display it.
If it is a Windows platform, the general manufacturer will also provide DLL and other call libraries, so that only relevant interface functions can be called to implement the relevant functions, but if it is an embedded platform, it is relatively troublesome. Generally, You need to develop relevant drivers based on the communication protocol.
Regardless of the method used, we have implemented this function. However, after a while, the RFID device and the camera device have changed, most of our code will usually be voided, and we need to re-develop the relevant driver, if this is a project that has been installed on the site and the sensor equipment is temporarily replaced, it is a dream for the development manufacturer.
This type of program development based on the IOT middleware platform will avoid such problems.
(1). The platform comes with related drivers (you can also develop it on your own and reuse it later ).
(2) remote configuration, remote deployment, and driver replacement at any time.
(3) The driver is completely decoupled from the business logic.
The following uses RFID card swiping as an example to describe how to develop related programs based on yfios Iot middleware platform.
We will not introduce how to develop RFID and camera drivers in this article. We will directly use the drivers we have developed (for those interested in driver development, refer to this article: yfios driver development guide).
RFIDDriver Configuration
We only need the following configuration for the easy-to-use serial port RFID driver.
(1) create a user device and select the drive of the yhy632 RFID card reader.
(2) configure the device parameters, select the serial port connected to the device, and configure the serial port parameters.
(3) All other parameters are default. If you select the variable check box to automatically add the variable, you do not need to manually create the variable.
Variable automatically added (device name: keyword)
Camera driver Configuration
Select the driver of the corresponding model, set the serial port number and serial port parameters, and select the variable auto-add option.
The scan cycle of the driver must be set to 0, indicating that the driver will not run automatically.
Business logic programming (Policy Development)
The business logic is relatively simple: first determine whether the rfidcard is flushed. If it is flushed, take a photo.
Based on this business logic, in order to reduce resource usage, we use the event Method to trigger the execution of this policy. That is, after the driver executes the policy once, it calls the policy once and transmits the result of the driver program running to the policy.
Public int onrun (ioperate op, strategymode mode, object Arg)
{
Int val = (INT) ARG;
If (val = 0)
{
Bitmap BMP = NULL;
// Call the camera driver. The device name must be consistent with the configuration.
Int ret = op. driverrun ("cameradriver", null );
If (ret = 0)
{
Int hander = op. iobc_create (op. ioread ("cameradriver: blockname"), 0 );
If (hander> = 0)
{
Int COUNT = op. iobc_getlength (hander );
Byte [] datasrc = new byte [count];
Op. iobc_read (hander, datasrc, 0, count );
Op. iobc_close (hander );
BMP = new Bitmap (datasrc, bitmap. bitmapimagetype. JPEG );
BMP. Flush ();
}
}
Return 0;
}
The above code is relatively simple. There are several points to describe:
(1) The object Arg parameter is related to the calling mechanism. In the event bound to the driver, the execution result of the driver is transmitted. If it is a policy calling policy, the related values are passed as needed. In this application, Arg is an integer. 0 indicates that the driver is successfully executed.
(2) call the driver according to the driver name.
(3) Interaction of large data blocks is completed through yfiobc data blocks.
After the policy is compiled, You need to load it:
The execution mode is Event Mode and bound to the RFID driver. Call this policy after the onrun function of the driver is executed, and pass the execution result to the policy as a parameter.
For more information about policy development, see yfios Policy Development Guide.
Deployment and running
Device replacement
The biggest advantage of Iot intermediate platform is device replacement. If we need to change the camera, we don't need to change any code, just change the camera driver.
-----------------------------------------------------------------------------
Mf Introduction: http://blog.csdn.net/yefanqiu/article/details/5711770
Mf data: http://www.sky-walker.com.cn/News.asp? Id = 25
Technical Forum: http://www.yfiot.net