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 ) );
Request := dword_to_dint( WriteRequest( RTC_SET_TIME, sizeof( TRtcTime ) ) );
CDIoctl( hRtc, Request, dword_to_dint( adr( rtctime ) ), adr( Result ) );
can i use these macros to work with hardware watchdog?
Log in to post a comment.
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?