Home
hariprasad
wiki
(WikiPage)
This is the personal project of hariprasad. This project is created automatically during user registration as an easy place to store personal data that doesn't need its own project such as cloned repositories.
Last updated: 2022-09-09
(no subject)
hariprasad
wiki
(Thread)
Last updated: 2022-09-09
Post by oooo on #10 SysSockPingAsync
IEC Snippets
snippets
(Post)
OK, Thank you i-campbell.
Last updated: 2022-09-10
Ticket #10: SysSockPingAsync
IEC Snippets
snippets
(Ticket)
SysSockPing is a synchronous function - if you call it in your code it will block that task until the ping timeout expires. There is an alternative SysSockPingAsync, but the code snippet (below) is a little longer. Really one should also call syssockasyncfb.RemoveAllJobs() on application shutdown, but they will timeout anyway themselves. PROGRAM PLC_PRG VAR syssockasyncfb : SysSocketAsync.SysSockAsyncFB; instAsyncJobParam : SysSocketAsync.ASYNCJOB_PARAM; taskname : STRING := 'Taskname'; taskhandle : SysSocketAsync.RTS_IEC_HANDLE := SysSocketAsync.SysTypes.RTS_INVALID_HANDLE; paramis: SysSocketAsync.tSysSockPing; state: UDINT; //SysSocketAsync.CmpAsyncMgr.GVL result: SysSocketAsync.RTS_IEC_RESULT; replyTime: UDINT; out: SysSocketAsync.RTS_IEC_RESULT; PING: BOOL; handle: SysSocketAsync.RTS_IEC_HANDLE; resultSetJobParam: SysSocketAsync.RTS_IEC_RESULT; END_VAR //general parameters for the async manager instAsyncJobParam.TaskParam.pszTaskname := ADR(taskname); //you could probably put a useful name here instAsyncJobParam.TaskParam.ulTaskPriority := 128; //very low runtime priority instAsyncJobParam.TaskParam.ulTaskSleepTime := 0; //"not used, set to 0" instAsyncJobParam.TaskParam.phTaskHandle := ADR(taskhandle); instAsyncJobParam.TaskParam.ulEndTaskAfterJob := 1; //why not? // parameters for the ping itself paramis.pszIpAddress := '192.168.56.122'; paramis.ulTimeout := 1000; //ms paramis.pulReplyTime := ADR(replyTime); //when the job is finished, the reply time will be stored here paramis.pulOut := ADR(out); //when the job is finished, the result will be stored here //just call the SysSockPingAsync once, and it starts the job. You know it is finished, when PLC_PRG.state = 2 IF PING THEN PING := FALSE; resultSetJobParam := syssockasyncfb.AsyncSetJobParams(ulAsyncJobType:= SysSocketAsync.CmpAsyncMgr.GVL.ASYNCJOB_TASK, ulTimeout:= paramis.ulTimeout * 2, pAsyncJobParams:= ADR(instAsyncJobParam)); handle := syssockasyncfb.SysSockPingAsync(pParam:= ADR(paramis), pudState:= ADR(state), pResult:= ADR(result)); END_IF ~~~2022-09-10 14:51:01.042000 Ticket #10: SysSockPingAsync IEC Snippets iec-snippets tickets snippets False /tol/iec-snippets/snippets/10/ Ticket SysSockPingAsync False 1 2022-06-15 11:00:21.597000 10 SysSockPingAsync Unlicensed SysSockPing is a synchronous function - if you call it in your code it will block that task until the ping timeout expires. There is an alternative SysSockPingAsync, but the code snippet (below) is a little longer. Really one should also call syssockasyncfb.RemoveAllJobs() on application shutdown, but they will timeout anyway themselves. ~~~ST PROGRAM PLC_PRG VAR syssockasyncfb : SysSocketAsync.SysSockAsyncFB; instAsyncJobParam : SysSocketAsync.ASYNCJOB_PARAM; taskname : STRING := 'Taskname'; taskhandle : SysSocketAsync.RTS_IEC_HANDLE := SysSocketAsync.SysTypes.RTS_INVALID_HANDLE; paramis: SysSocketAsync.tSysSockPing; state: UDINT; //SysSocketAsync.CmpAsyncMgr.GVL result: SysSocketAsync.RTS_IEC_RESULT; replyTime: UDINT; out: SysSocketAsync.RTS_IEC_RESULT; PING: BOOL; handle: SysSocketAsync.RTS_IEC_HANDLE; resultSetJobParam: SysSocketAsync.RTS_IEC_RESULT; END_VAR //general parameters for the async manager instAsyncJobParam.TaskParam.pszTaskname := ADR(taskname); //you could probably put a useful name here instAsyncJobParam.TaskParam.ulTaskPriority := 128; //very low runtime priority instAsyncJobParam.TaskParam.ulTaskSleepTime := 0; //"not used, set to 0" instAsyncJobParam.TaskParam.phTaskHandle := ADR(taskhandle); instAsyncJobParam.TaskParam.ulEndTaskAfterJob := 1; //why not? // parameters for the ping itself paramis.pszIpAddress := '192.168.56.122'; paramis.ulTimeout := 1000; //ms paramis.pulReplyTime := ADR(replyTime); //when the job is finished, the reply time will be stored here paramis.pulOut := ADR(out); //when the job is finished, the result will be stored here //just call the SysSockPingAsync once, and it starts the job. You know it is finished, when PLC_PRG.state = 2 IF PING THEN PING := FALSE; resultSetJobParam := syssockasyncfb.AsyncSetJobParams(ulAsyncJobType:= SysSocketAsync.CmpAsyncMgr.GVL.ASYNCJOB_TASK, ulTimeout:= paramis.ulTimeout * 2, pAsyncJobParams:= ADR(instAsyncJobParam)); handle := syssockasyncfb.SysSockPingAsync(pParam:= ADR(paramis), pudState:= ADR(state), pResult:= ADR(result)); END_IF False False 1 0 1 None i-campbell i-campbell
Last updated: 2022-09-10
wiki Discussion
kishan
wiki
(Discussion)
Forum for wiki comments
Last updated: 2022-09-10
blog Discussion
kishan
blog
(Discussion)
Forum for blog comments
Last updated: 2022-09-10
(no subject)
kishan
wiki
(Thread)
Last updated: 2022-09-10
Home
tarcisioalmeida
wiki
(WikiPage)
This is the personal project of tarcisioalmeida. This project is created automatically during user registration as an easy place to store personal data that doesn't need its own project such as cloned repositories.
Last updated: 2022-09-11
wiki Discussion
nano
wiki
(Discussion)
Forum for wiki comments
Last updated: 2022-09-11
blog Discussion
nano
blog
(Discussion)
Forum for blog comments
Last updated: 2022-09-11
(no subject)
nano
wiki
(Thread)
Last updated: 2022-09-11
Home
dutchplc
wiki
(WikiPage)
This is the personal project of dutchplc. This project is created automatically during user registration as an easy place to store personal data that doesn't need its own project such as cloned repositories.
Last updated: 2022-09-12
wiki Discussion
dutchplc
wiki
(Discussion)
Forum for wiki comments
Last updated: 2022-09-12
blog Discussion
dutchplc
blog
(Discussion)
Forum for blog comments
Last updated: 2022-09-12
(no subject)
dutchplc
wiki
(Thread)
Last updated: 2022-09-12
Home
acend
wiki
(WikiPage)
This is the personal project of acend. This project is created automatically during user registration as an easy place to store personal data that doesn't need its own project such as cloned repositories.
Last updated: 2022-09-13
Home
duvan-moreno
wiki
(WikiPage)
This is the personal project of duvan-moreno. This project is created automatically during user registration as an easy place to store personal data that doesn't need its own project such as cloned repositories.
Last updated: 2022-09-14
Home
drawson
wiki
(WikiPage)
This is the personal project of drawson. This project is created automatically during user registration as an easy place to store personal data that doesn't need its own project such as cloned repositories.
Last updated: 2022-09-14
(no subject)
drawson
wiki
(Thread)
Last updated: 2022-09-14
Home
abdel
wiki
(WikiPage)
This is the personal project of abdel. This project is created automatically during user registration as an easy place to store personal data that doesn't need its own project such as cloned repositories.
Last updated: 2022-09-15
wiki Discussion
abdel
wiki
(Discussion)
Forum for wiki comments
Last updated: 2022-09-15
blog Discussion
abdel
blog
(Discussion)
Forum for blog comments
Last updated: 2022-09-15
(no subject)
abdel
wiki
(Thread)
Last updated: 2022-09-15
Home
carlos-fegam
wiki
(WikiPage)
This is the personal project of carlos-fegam. This project is created automatically during user registration as an easy place to store personal data that doesn't need its own project such as cloned repositories.
Last updated: 2022-09-15
Home
edepalos
wiki
(WikiPage)
This is the personal project of edepalos. This project is created automatically during user registration as an easy place to store personal data that doesn't need its own project such as cloned repositories.
Last updated: 2022-09-16