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
Diff: main.cpp
- Revision:
- 1:a57cbebba3fd
- Parent:
- 0:03ab7f7596e2
- Child:
- 2:ec972966689e
--- a/main.cpp Wed Sep 11 11:40:34 2019 +0000 +++ b/main.cpp Wed Sep 11 18:28:09 2019 +0000 @@ -40,13 +40,20 @@ bool isactive; bool closeconnection; int sockalivetime; -} net1,http1; +} net1,nets,http1; + +bool polltick; BufferedSerial sport0(PD_5, PD_6, 256, 4); // UART2 Thread conchkthread[2]; Thread rxtxdatathread[2]; +void heartbeat() +{ + polltick=true; +} + void nettimeout(netsys *net2) { if (net2->isactive==true) @@ -140,6 +147,8 @@ printf("The target IP address is '%s'\r\n", eth.get_ip_address()); + nsapi_error_t ret; + /* Open the server on ethernet stack */ net1.srv.open(ð); net1.isactive=false; @@ -155,20 +164,19 @@ net1.srv.bind(net1.tcpport); /* Can handle 5 simultaneous connections */ - net1.srv.listen(1); + net1.srv.listen(5); http1.srv.listen(5); - sport0.baud(9600); conchkthread[0].start(callback(conchk,&net1)); nettimer[0].attach(callback(nettimeout,&net1),1); + nettimer[1].attach(heartbeat,10); rxtxdatathread[0].start(callback(datanrx,&net1)); rxtxdatathread[1].start(callback(datasrx,&net1)); - conchkthread[1].start(callback(conchk,&http1)); while (true) { - while (net1.isactive) + if (net1.isactive) { if (net1.closeconnection==true) { @@ -179,5 +187,19 @@ } } + if (polltick) + { + polltick=false; + 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); + ret = nets.clt_sock.connect("10.150.1.245",23000); + printf("Connected %d\r\n",ret); + ret = nets.clt_sock.send("Tick",strlen("Tick")); + printf("Send Result %d\r\n",ret); + nets.clt_sock.close(); + } } }