[Iot middleware platform-04] yfios driver development guide

Source: Internet
Author: User
Document directory
  • 2.5.1 driver compilation and Loading
  • 2.5.2 add user devices
  • 2.5.3 configure Project Properties
  • 2.5.4 project deployment and debugging
  • 2.5.5 project operation

 

Document Name

Yfios driver development guide

Version

V1.0.0

Author

Ye fan

Date

2012-12-25

History

 

Document list

Http://www.sky-walker.com.cn/MFRelease/YF_document_list.pdf

1 yfios Introduction

Yfios is short for yfsoft I/O server. In the IOT and cloud computing era, everything is data-centric. Different sensors access the network in different ways, provide services to different end users through cloud computing.

In order to adapt to the development of this new situation, it accelerates and reduces the cost of various sensors and smart modules to the Internet. net micro framework system to build a lightweight embedded Configuration System in the IOT Era --Yfios.

For more information, see yfios technical whitepaper.

2. driver development 2.1 yfios SDK Installation

See the yfios Installation Guide.

2.2 create a driver

 

Select the yfios driver template for driver development.

2.3 Code Template

 

Public driverinfo getdriverinfo () {driverinfo info = new driverinfo (); // driver name info. name = This. name; // version info. ver = "v1.0.0"; // description info. explain = "virtual serial port device"; // developer info. developer = "yefan"; // development date info. date = "2011-10-18 "; // automated flag // 0 bit 0-the system initializes the communication interface for you 1-the communication interface Initialization is completed by the driver itself/1 bit 0-no operation 1-completed by the driver itself add Io variables // 2 ~ 31 bit backup info. autoflag = 0; // connmode-manufacturer-devicetype is the unique identifier of the driver. // The communication method info. connmode = deviceconnmode. serialPort; // manufacturer info. manufacturer = "yfsoft"; // device type info. devicetype = "virtualdevice"; // port configuration info. portaddrexplain = "serial port number:"; info. portaddrvalue = "COM1 | com2 | com3 | com4 | com5 | com6 | COM7 | com8"; info. portconfigexplain = "Serial Port parameters:"; info. portconfigvalue = "9600, N,"; // configure info for the device. deviceaddrexplain = ""; info. deviceaddrvalue = ""; info. deviceconfigexplain = ""; info. deviceconfigvalue = ""; info. itemexplain = new string [1]; info. itemvalue = new string [1]; info. itemexplain [0] = "Data Type:"; info. itemvalue [0] = "v | commstate"; return Info ;}

 

The Code Template automatically generates the above Code.

This is a virtual serial port device template. You can configure parameters based on the characteristics of the actual sensor and the interface.

2.4 Hello World

In the onrun function, add the following code:

Public int onrun (device DV, ioperate op, object Arg)

{

If (DV. debugmode! = 0) op. Print (messagetype. sysdebug, "onrun", this. Name );

 Op. Print (messagetype. Information, "Hello world !!! ", This. Name );

Return 0;

}

2.5 driver test 2.5.1 driver compilation and Loading

Compile the above Code and copy the yfiosdriver1.dll and yfiosdriver1.pe files under the yfiosdriver1 \ bin \ debug \ le directory to the C: \ Program Files (x86) \ yfios \ yfiosmanager \ driver directory.

Then run yfiosmanager.exe.

 

In the driver list, you can see the written driver information, as shown in ).

2.5.2 add user devices

 

Click User devices in the tree control, and double-click Create... in the list control ...] The User device form is displayed.

We choose the virtualdevice driver under the serial driver, that is, the driver we just compiled.

We name it "hellodevice ",Serial port number.Com3, And then save.

2.5.3 configure Project Properties

Click project properties in the tree control and double-click Configuration data in the list control. The following page is displayed. By default, user debugging, general information, and system debugging information are not checked.

 

Select all options.

2.5.4 project deployment and debugging

After saving the project, click debug> deploy (or click the deployment icon) to deploy the project.

 

2.5.5 project operation

Click debug> start to start the project.

 

In the information output window, we can see that the driver has been correctly loaded and the Hello world !!!

3. Driver debugging

Although the written driver can be debugged in yfiosmanager by means of information output, this debugging method is not ideal if the driver is complicated.

Therefore, we construct a tinyiosemulator to debug the driver in the Visual Studio 2010 environment.

Because yfsoft. drivertest is a standard. Net micro framework program, you need to set the system to. Net micro framework system mode during debugging.

 

Ensure that pf9 And Gnd are connected.

3.1 Build tinyiosemulator

 

The tinyiosemulator project must reference the driver we just created.

The main code for testing is as follows:

    public class YFIOsEmulator    {        YFIOS ios = new YFIOS();        Device device = new Device();        public void Run()        {            IDriver md = TestVirtualDevice();            md.OnLoad(device, ios.operate, null);            while (true)            {                md.OnRun(device, ios.operate, null);                Thread.Sleep(3000);            }        }         public IDriver TestVirtualDevice()        {            device.PortAddr = 1;            device.PortConfig = "9600,n,8,1";            device.DebugMode = 0;            device.DeviceAddr = 0;            device.DeviceConfig = "";            device.IOItems = new ArrayList();            OpenPort(device, ios.operate);            return new YFIOsDriver1();        } }

 

3.2 single-step debugging

 

As you can see, in the Visual Studio development environment, we can debug it, And the debugging window also outputs Hello world !!! Information.

4 additional instructions

This article is just an article about driving development. To write a complicated driver, you also need to learn a variety of development knowledge.

High-level driver development related content is as follows:

(1) driver variable design;

(2) read and write the driver;

(3) Development of driver Extension Configuration panel;

(4) The driver code references the third library;

(5) driving yfiobc operations;

(6) directly call the driver for a policy;

5. Related Resources

1.. Net micro framework Official Website

Http://www.microsoft.com/netmf/default.mspx

2.. Net micro framework official blog

Http://blogs.msdn.com/netmfteam/

3. Chinese Blog

Http://blog.csdn.net/yefanqiu

Http://www.cnblogs.com/yefanqiu

4. Ye Fan Technology

Http://www.sky-walker.com.cn/

5. Iot Middleware Technology Development Forum

Http://www.yfios.net

 

Yfios/yfhmi free trial

Yfios and yfhmi will be available for free for six months from January 21,. Users who meet the application requirements will receive yfios and yfhmi trial opportunities in turn.

Application form download: http://sky-walker.com.cn/MFRelease/document/yfios_yfhmi_application.doc

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.