⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme.txt

📁 THIS CODE IS FOR EXAMPLE PURPOSES ONLY, USE AT YOUR OWN RISK, NO WARRANTY IS ASSUMED OR IMPLIED
💻 TXT
字号:
myProtocol - Example custom protocol for vxWorks (Modbus over Ethernet) 

 Copyright 1992-2002 Wind River Systems, Inc. 
   
THIS CODE IS FOR EXAMPLE PURPOSES ONLY, USE AT YOUR OWN RISK, NO WARRANTY 
IS ASSUMED OR IMPLIED   


The intension of this code is to provide an example of attaching to the MUX layer with a custom
ethernet protocol. Though the NPT code is provided for handling alternate frames, it has not been tested.

The END support functions are prefixed with myProtocol ..
The NPT support functions are prefixed with myProtoNpt..
The Modbus specific functions are prefixed with modbus.. 

This protocol example implements the Modbus protocol over Ethernet. This is not the published 
open standard, which implements Modbus over TCP/IP, (Please see www.modbus.org ). 
In our example the TCP/IP layers are eliminated for the purpose illustrating the use of a custom 
protocol on vxWorks. Modbus was chosen because it is a very simple open standard, 
and the author is familiar with it. 

For those not familiar with Modbus it is an industrial master/slave protocol.
The slaves are the publishers of 1 bit and 16 bit numeric data, originally used for 
communication between devices in an RS232 or RS485 serial network. 

To use the example code, place the files in a Tornado bootable project directory and add the file myProtocol.c to the project, configure the project for networking, and compile.

You will need two target boards on the same subnet running this code.

On one board the following code must be run, 

myProtocolInit(sysBootParams.bootDev, 0)

on the other you must make some requests..


#define MAC_ADRS "00:e0:4b:00:fd:61"

void doModbus (void)
{
   modbus("write", 1, "holding", "43@"MAC_ADRS, 1);
   taskDelay(10);
   modbus("write", 2, "holding", "44@"MAC_ADRS, 1, 2);
   taskDelay(10);
   modbus("write", 3, "holding", "45@"MAC_ADRS, 1, 2, 3);
   taskDelay(10);
   modbus("write", 4, "holding", "46@"MAC_ADRS, 1, 2, 3, 4);
   taskDelay(10);
   modbus("write", 5, "holding", "47@"MAC_ADRS, 1, 2, 3, 4,5);
   taskDelay(10);
   modbus("write", 6, "holding", "48@"MAC_ADRS, 1, 2, 3, 4,5,6);
   taskDelay(10);
   modbus("write", 7, "holding", "49@"MAC_ADRS, 1, 2, 3, 4,5,6,7);
   taskDelay(10);
   modbus("write", 8, "holding", "50@"MAC_ADRS, 1, 2, 3, 4,5,6,7,8);
   taskDelay(10);
   modbus("write", 9, "holding", "51@"MAC_ADRS, 1, 2, 3, 4,5,6,7,8,9);
   taskDelay(10);
   modbus("write", 10, "holding", "52@"MAC_ADRS, 1, 2, 3, 4,5,6,7,8,9,10);
   taskDelay(10);
   modbus("write", 11, "holding", "53@"MAC_ADRS, 1, 2, 3, 4,5,6,7,8,9,10,11);
   taskDelay(10);
   modbus("write", 12, "holding", "54@"MAC_ADRS, 1, 2, 3, 4,5,6,7,8,9,10,11,12);
   taskDelay(10);
   modbus("write", 13, "holding", "55@"MAC_ADRS, 1, 2, 3, 4,5,6,7,8,9,10,11,12,13);
   taskDelay(10);
   modbus("write", 14, "holding", "56@"MAC_ADRS, 1, 2, 3, 4,5,6,7,8,9,10,11,12,13,14);
   taskDelay(10);
   modbus("read",  30, "holding", "42@"MAC_ADRS);
   taskDelay(50);
    }


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -