CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Sat Sep 21, 2019 10:18 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 1 post ] 
Author Message
 Post subject: Hardware Watchdog
PostPosted: Tue Jun 18, 2019 1:36 pm 
Offline

Joined: Mon Jul 30, 2018 12:41 pm
Posts: 2
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?


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 1 post ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited