gos7 icon indicating copy to clipboard operation
gos7 copied to clipboard

About Set/Get PLC time function

Open whitetiger21022014 opened this issue 4 years ago • 2 comments

Hi Robinson, PGClockWrite (implement GetPLCDateTime) , is it a mistake between 2 functions?

//implement GetPLCDateTime func (mb *client) PGClockWrite() (datetime time.Time, err error)

//implement SetPLCDateTime func (mb *client) PGClockRead(datetime time.Time) (err error) {

whitetiger21022014 avatar Dec 24 '20 08:12 whitetiger21022014

hi when you use PGClockRead to set time of plc,do you produce a panic?

zhangzijie-820 avatar Jul 14 '21 03:07 zhangzijie-820

I believe there are multiple issues in datetime.go PGClockRead / PGClockWrite function names are reversed - just confusing mb.send does not catch error and so will panic if PLC is disconnected s7.SetDateTimeAt(requestData, 32, datetime). I had to change this to s7.SetDateTimeAt(requestData, 31, datetime) to format date correctly.

PS. I am new to github. Happy to post my fixed datetime.go if required PPS. Great job with gos7.

arhray avatar Dec 22 '23 10:12 arhray