sbcshop / USB-RTC-Software

USB RTC is an open source real time clock device that comprises MCP2221, a USB-to-UART/I2C serial converter, which enables USB connectivity, in the processes that include a USB, UART(Serial), GPIO, and I2C interfaces.
GNU General Public License v3.0
11 stars 3 forks source link

Set_Time: NowTime format ? (hex??) #7

Open Pbottelin opened 2 years ago

Pbottelin commented 2 years ago

Hi, and thanks for the design and codes provided with the USB RTC.

I am using this device to maintain the timing of a Raspberry Pi whatever the status of its ethernet connexion.

I am struggling when I attempt to set the correct time into the RTC, at line: NowTime = [0x00,0x00,0x18,0x04,0x12,0x08,0x15] More precisely, I am unsure of the type of each element in the list. Are they hexadecimal numbers?

The NowTime above gives 2015-08-12 Wednesday 18:00:00 But if I try hex(2015) in python, this does not yield 0x15 but '0x7df'..

Could you provide more detaield information about the NowTime to feed into the SetTime function please?

Thanks very much, Best regards

Pierre

Pbottelin commented 2 years ago

To precise my above-mentioned issue, when I use the Set_Time_From_Sysclock.py script with int('string', 16) encoding for NowTime, I get the follwing issue:

File "/home/pi/rtc/module_RTC.py", line 23, in ds3231ReadTime bus = SMBus.SMBus() File "/usr/local/lib/python3.7/dist-packages/PyMCP2221A/SMBus.py", line 13, in init self.mcp2221 = PyMCP2221A.PyMCP2221A(VID,PID,devnum) File "/usr/local/lib/python3.7/dist-packages/PyMCP2221A/PyMCP2221A.py", line 16, in init self.mcp2221a.open_path(hid.enumerate(VID, PID)[devnum]["path"]) File "hid.pyx", line 125, in hid.device.open_path OSError: open failed python3: ../../libusb/io.c:2116: handle_events: Assertion `ctx->pollfds_cnt >= internal_nfds' failed. Aborted