pcdshub / lcls-twincat-general

A PLC code toolkit for LCLS TwinCAT PLC projects
https://pcdshub.github.io/lcls-twincat-general/
Other
16 stars 20 forks source link

REF: refactor FB_Logger based on FB_ConnectionlessSocket #4

Closed klauer closed 5 years ago

klauer commented 5 years ago

As best as I can tell, the current master is based partly on old code that used FB_SocketUdpCreate, which required much more in the way of state tracking. That's been cleaned up in this PR and drastically simplified.

As this is my first bit of non-trivial PLC code, you might want to look over the changes closely...

Changes / Notes

Testing

if xInit = 1 then
    xInit := 0;
    logger(i_xReset:=TRUE);
END_IF

iCycle := iCycle + 1;

IF (iCycle MOD 500) = 0 THEN
    GVL_Logger.fbLogMessage(
             i_sMsg:='message',
             i_eSevr:=E_MesgSevr.Debug,
             i_eSubsystem:=E_Subsystem.MOTION
             );
END_IF
logger();

And using nc as a syslog stand-in /usr/bin/nc -u -l 59999 -b <interface>, I periodically see:

<167> 1 2019-07-15T20:22:19.145Z MOTION - - BOMmessage

Requirements

TODO

cc @teddyrendahl

klauer commented 5 years ago

@ZLLentz fair enough!

slacAWallace commented 5 years ago

Working on this now.

slacAWallace commented 5 years ago

I was able to confirm the PLC is sending out syslog formatted messages using wireshark so it seems changing to the connectionless socket fb worked.

klauer commented 5 years ago

👏