robinson / gos7

Implementation of Siemens S7 protocol in golang
BSD 3-Clause "New" or "Revised" License
314 stars 121 forks source link

About Set/Get PLC time function #42

Open whitetiger21022014 opened 3 years ago

whitetiger21022014 commented 3 years ago

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) {

zhangzijie-820 commented 3 years ago

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

arhray commented 8 months ago

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.