From 885c3176a8866e8e849475061664bdf3176bf3c7 Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Fri, 18 Aug 2023 17:34:54 +0100 Subject: [PATCH] - renamed RSession_startlistening to RSession_start to indicate that it is also required for the publisher side - updates R-GOOSE and R-SMV publisher examples with RSession_start call to bind to an UDP port/interface --- .../r_goose_publisher_example/r_goose_publisher_example.c | 4 ++++ examples/rsv_publisher_example/r_sv_publisher_example.c | 6 ++++-- src/goose/goose_receiver.c | 2 +- src/r_session/r_session.c | 4 ++-- src/r_session/r_session.h | 8 ++++---- src/sampled_values/sv_subscriber.c | 4 ++-- 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/examples/r_goose_publisher_example/r_goose_publisher_example.c b/examples/r_goose_publisher_example/r_goose_publisher_example.c index 9ec300bb..d61e52ce 100644 --- a/examples/r_goose_publisher_example/r_goose_publisher_example.c +++ b/examples/r_goose_publisher_example/r_goose_publisher_example.c @@ -40,6 +40,8 @@ main(int argc, char **argv) signal(SIGINT, sigint_handler); + /* Call RSession_setLocalAddress to use a particular interface to send the R-GOOSE messages */ + //RSession_setLocalAddress(rSession, "169.254.110.126", -1); RSession_setRemoteAddress(rSession, dstAddress, 102); LinkedList dataSetValues = LinkedList_create(); @@ -67,6 +69,8 @@ main(int argc, char **argv) GoosePublisher_setDataSetRef(publisher, "simpleIOGenericIO/LLN0$AnalogValues"); GoosePublisher_setTimeAllowedToLive(publisher, 500); + RSession_start(rSession); + while (running) { int i = 0; diff --git a/examples/rsv_publisher_example/r_sv_publisher_example.c b/examples/rsv_publisher_example/r_sv_publisher_example.c index 8256ee6a..e4dad561 100644 --- a/examples/rsv_publisher_example/r_sv_publisher_example.c +++ b/examples/rsv_publisher_example/r_sv_publisher_example.c @@ -23,8 +23,8 @@ main(int argc, char** argv) if (rSession) { - //RSession_setRemoteAddress(sessionP, "192.168.56.101", 102); - //RSession_setRemoteAddress(rSession, "192.168.2.227", 102); + /* Call RSession_setLocalAddress to use a particular interface to send the R-GOOSE messages */ + //RSession_setLocalAddress(rSession, "169.254.110.126", -1); RSession_setRemoteAddress(rSession, "230.0.10.10", 102); SVPublisher svPublisher = SVPublisher_createRemote(rSession, 0x4000); @@ -61,6 +61,8 @@ main(int argc, char** argv) float fVal1 = 1234.5678f; float fVal2 = 0.12345f; + RSession_start(rSession); + while (running) { Timestamp ts; Timestamp_clearFlags(&ts); diff --git a/src/goose/goose_receiver.c b/src/goose/goose_receiver.c index ff5101cc..833fb2ff 100644 --- a/src/goose/goose_receiver.c +++ b/src/goose/goose_receiver.c @@ -1185,7 +1185,7 @@ GooseReceiver_startThreadless(GooseReceiver self) { #if (CONFIG_IEC61850_R_GOOSE == 1) if (self->session) { - if (RSession_startListening(self->session) == R_SESSION_ERROR_OK) { + if (RSession_start(self->session) == R_SESSION_ERROR_OK) { self->running = true; return (EthernetSocket)1; diff --git a/src/r_session/r_session.c b/src/r_session/r_session.c index 973a1f01..c740e314 100644 --- a/src/r_session/r_session.c +++ b/src/r_session/r_session.c @@ -232,7 +232,7 @@ RSession_setRemoteAddress(RSession self, const char* remoteAddress, int remotePo } RSessionError -RSession_startListening(RSession self) +RSession_start(RSession self) { if (self->socket) { @@ -254,7 +254,7 @@ RSession_startListening(RSession self) } RSessionError -RSession_stopListening(RSession self) +RSession_stop(RSession self) { Semaphore_wait(self->socketLock); diff --git a/src/r_session/r_session.h b/src/r_session/r_session.h index 438d6bf7..662e8846 100644 --- a/src/r_session/r_session.h +++ b/src/r_session/r_session.h @@ -150,24 +150,24 @@ LIB61850_API RSessionError RSession_setRemoteAddress(RSession self, const char* remoteAddress, int remotePort); /** - * \brief Start listening on the local UDP port to receive remote messages (only for subscriber) + * \brief Start sending and receiving messages (bind to a local UDP port/interface) * * \param self the RSession instance * * \return R_SESSION_ERROR_OK on success, error code otherwise */ LIB61850_API RSessionError -RSession_startListening(RSession self); +RSession_start(RSession self); /** - * \brief Stop listening on the local UDP port (only for subscriber) + * \brief Stop sending and receiving messages. * * \param self the RSession instance * * \return R_SESSION_ERROR_OK on success, error code otherwise */ LIB61850_API RSessionError -RSession_stopListening(RSession self); +RSession_stop(RSession self); /** * \brief Manually add a key to the RSession instance diff --git a/src/sampled_values/sv_subscriber.c b/src/sampled_values/sv_subscriber.c index 82833056..9ece29e5 100644 --- a/src/sampled_values/sv_subscriber.c +++ b/src/sampled_values/sv_subscriber.c @@ -312,7 +312,7 @@ SVReceiver_startThreadless(SVReceiver self) { #if (CONFIG_IEC61850_R_SMV == 1) if (self->session) { - if (RSession_startListening(self->session) == R_SESSION_ERROR_OK) { + if (RSession_start(self->session) == R_SESSION_ERROR_OK) { self->running = true; return true; @@ -352,7 +352,7 @@ SVReceiver_stopThreadless(SVReceiver self) #if (CONFIG_IEC61850_R_SMV == 1) if (self->session) { - RSession_stopListening(self->session); + RSession_stop(self->session); } #endif /* (CONFIG_IEC61850_R_SMV == 1) */