This demonstrates the process of communicating through ethernet to a SEL-2431 Voltage Regulator Control Panel using SEL Fast Message. Basic device commands and data cna be requested and displayed over a connected serial port. This is a basic version and full testing and documentation has yet to be completed.
Dependencies: BufferedSerial analogAverager voltageRegulator netStatReg analogMinMax CounterMinMax
Revision 2:ec972966689e, committed 2019-09-11
- Comitter:
- masterkookus
- Date:
- Wed Sep 11 19:02:43 2019 +0000
- Parent:
- 1:a57cbebba3fd
- Child:
- 3:ac1f2af8bd0f
- Commit message:
- Added Comments
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Sep 11 18:28:09 2019 +0000 +++ b/main.cpp Wed Sep 11 19:02:43 2019 +0000 @@ -49,11 +49,13 @@ Thread conchkthread[2]; Thread rxtxdatathread[2]; +//Provides the deivce poll timing void heartbeat() { polltick=true; } +//Provides the timeout for ethernet to serial communications void nettimeout(netsys *net2) { if (net2->isactive==true) @@ -70,6 +72,7 @@ } } +//Ethernet to Serial transmit data void datanrx(netsys *net2) { char rxbuf[256]; @@ -85,6 +88,7 @@ } } +//Ethernet to Serial receive data void datasrx(netsys *net2) { char rxbuf[256]; @@ -108,6 +112,7 @@ } } +//Checks for a Ethernet to Serial connection void conchk(netsys *net2) { TCPServer *server=&(net2->srv); @@ -147,6 +152,7 @@ printf("The target IP address is '%s'\r\n", eth.get_ip_address()); + /* Error Messages */ nsapi_error_t ret; /* Open the server on ethernet stack */ @@ -159,7 +165,7 @@ http1.tcpport=80; http1.srv.bind(http1.tcpport); - /* Bind port 23000 to the server */ + /* Bind port 23 to the server */ net1.tcpport=23; net1.srv.bind(net1.tcpport); @@ -168,11 +174,17 @@ http1.srv.listen(5); sport0.baud(9600); + /* Setup Ethernet to Serial Connection Thread */ conchkthread[0].start(callback(conchk,&net1)); + /* Setup Ethernet to Serial Timeout Ticker */ nettimer[0].attach(callback(nettimeout,&net1),1); + /* Setup polltick Ticker */ nettimer[1].attach(heartbeat,10); + /* Setup Ethernet to Serial transmit data Thread */ rxtxdatathread[0].start(callback(datanrx,&net1)); + /* Setup Ethernet to Serial receive data Thread */ rxtxdatathread[1].start(callback(datasrx,&net1)); + /* Setup Web Server Connection Thread */ conchkthread[1].start(callback(conchk,&http1)); while (true) { @@ -193,8 +205,8 @@ printf("Enter_Tick\r\n"); ret = nets.clt_sock.open(ð); printf("Socket%d\r\n",ret); - nets.clt_sock.set_blocking(true); - nets.clt_sock.set_timeout(1000); + //nets.clt_sock.set_blocking(true); + //nets.clt_sock.set_timeout(10); ret = nets.clt_sock.connect("10.150.1.245",23000); printf("Connected %d\r\n",ret); ret = nets.clt_sock.send("Tick",strlen("Tick"));