test public

Fork of Modbus by Cam Marshall

Revision:
1:a3ee8cb24540
Parent:
0:0453a0a7e500
Child:
2:9e76d51d9fb6
diff -r 0453a0a7e500 -r a3ee8cb24540 main.cpp
--- a/main.cpp	Thu Apr 15 12:10:34 2010 +0000
+++ b/main.cpp	Mon Jul 02 14:36:46 2018 +0000
@@ -22,12 +22,15 @@
 /* ----------------------- System includes --------------------------------*/
 
 /* ----------------------- Modbus includes ----------------------------------*/
+#include "mbed.h"
+#include "EthernetInterface.h"
 #include "mb.h"
 #include "mbport.h"
+#include "netconf.h"
 
 /* ----------------------- Defines ------------------------------------------*/
 #define REG_INPUT_START 1000
-#define REG_INPUT_NREGS 4
+#define REG_INPUT_NREGS 5
 #define SLAVE_ID 0x0A
 
 /* ----------------------- Static variables ---------------------------------*/
@@ -35,24 +38,39 @@
 static USHORT   usRegInputBuf[REG_INPUT_NREGS];
 
 /* ----------------------- Start implementation -----------------------------*/
+
+DigitalIn mybutton(USER_BUTTON);
+DigitalOut myled2(LED2);
+
 int
 main( void )
 {
     eMBErrorCode    eStatus;
 
-    eStatus = eMBInit( MB_RTU, SLAVE_ID, 0, 9600, MB_PAR_NONE );
-
+    //eStatus = eMBInit( MB_RTU, SLAVE_ID, 0, 9600, MB_PAR_NONE );
+    
+    EthernetInterface eth;
+    eth.set_network("169.254.178.1","255.255.0.0","169.254.178.3");
+    eth.connect();
+    
+    /* inicializacion del Stack de Modbus */
+    eMBTCPInit(502);
+    
     /* Enable the Modbus Protocol Stack. */
     eStatus = eMBEnable(  );
+    myled2=1;
     
     // Initialise some registers
-    usRegInputBuf[1] = 0x1234;
-    usRegInputBuf[2] = 0x5678;
-    usRegInputBuf[3] = 0x9abc;        
+    usRegInputBuf[1] = 83;
+    usRegInputBuf[2] = 65;
+    usRegInputBuf[3] = 76; 
+    usRegInputBuf[4] = 85;       
 
     for( ;; )
     {
         ( void )eMBPoll(  );
+        
+         LwIP_Pkt_Handle();
                 
         /* Here we simply count the number of poll cycles. */
         usRegInputBuf[0]++;