CODESYS - the IEC 61131-3 automation software
https://forum.codesys.com/

Hardware Watchdog
https://forum.codesys.com/viewtopic.php?f=11&t=9815
Page 1 of 1

Author:  Drongo96 [ Tue Jun 18, 2019 1:36 pm ]
Post subject:  Hardware Watchdog

Hello! I'm trying to work with hardware watchdog using ioctl, but nothing works.

As an example, I used the real time clock driver

var constant
RTC_RD_TIME: udint := 16#09;
RTC_SET_TIME: udint := 16#0a;
group: dword := 16#70;
IOC_OUT: dword := 16#80000000;
IOC_IN: dword := 16#40000000;
IOCPARM_MASK: dword := 16#1fff;
end_var

method private ReadRequest : dword
var_input
num: udint;
len: udint;
end_var

ReadRequest := IOC_OUT or ( shl( len and IOCPARM_MASK, 16 ) or ( shl( group, 8 ) or num ) );

method private WriteRequest : dword
var_input
num: udint;
len: udint;
end_var

WriteRequest := IOC_IN or ( shl( len and IOCPARM_MASK, 16 ) or ( shl( group, 8 ) or num ) );

// ...

hRtc := CDOpen( '/dev/rtc', CmpCharDevice.ACCESS_MODE.O_RDONLY, adr( Result ) );

if hRtc <> RTS_INVALID_HANDLE then

Request := dword_to_dint( ReadRequest( RTC_RD_TIME, sizeof( TRtcTime ) ) );

CDIoctl( hRtc, Request, dword_to_dint( adr( Read ) ), adr( Result ) );

CDClose( hRtc, adr( Result ) );

end_if

// ...

hRtc := CDOpen( '/dev/rtc', CmpCharDevice.ACCESS_MODE.O_WRONLY, adr( Result ) );

if hRtc <> RTS_INVALID_HANDLE then

Request := dword_to_dint( WriteRequest( RTC_SET_TIME, sizeof( TRtcTime ) ) );

CDIoctl( hRtc, Request, dword_to_dint( adr( rtctime ) ), adr( Result ) );

CDClose( hRtc, adr( Result ) );

end_if

can i use these macros to work with hardware watchdog?

Page 1 of 1 All times are UTC+01:00
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/