You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 20, 2024. It is now read-only.
I'm working on a python project on my Orange PC2 board with gpiod event on pin 40 (gpiochip1 - 199).
I got event when pin is linked to VCC (with Pull down), the event type is good but the timestamp is wrong as you can see below:
I made some tests and I don't known if there has any change made under the linux kernel but the original timestamp returned in the gpio_line_event_read_fd() function is not a timestamp but seems to be the time of the event since the OS uptime:
defgpiod_line_event_read_fd(fd: int, event: gpiod_line_event) ->int:
""" @brief Read the last GPIO event directly from a file descriptor. @param fd: File descriptor. @param event: Buffer in which the event data will be stored. @return 0 if the event was read correctly, -1 on error. Users who directly poll the file descriptor for incoming events can also directly read the event data from it using this routine. This function translates the kernel representation of the event to the libgpiod format. """evdata=gpioevent_data()
try:
rd=os_read(fd, sizeof(evdata))
exceptOSError:
return-1iflen(rd) !=sizeof(evdata):
set_errno(EIO)
return-1memmove(pointer(evdata), rd, sizeof(evdata))
event.event_type= (
GPIOD_LINE_EVENT_RISING_EDGEifevdata.id==GPIOEVENT_EVENT_RISING_EDGEelseGPIOD_LINE_EVENT_FALLING_EDGE
)
print(f"Original Event timestamp: {evdata.timestamp}")
print(f"Event timestamp (seconds only): {evdata.timestamp//1000000000}")
sec=evdata.timestamp//1_000_000_000event.ts=datetime(year=1970, month=1, day=1) +timedelta(
days=sec//86400,
seconds=sec%86400,
microseconds=(evdata.timestamp%1_000_000_000) //1000,
)
return0
Got the following result:
Waiting for event
Original Event timestamp: 2712700685261
Event timestamp (seconds only): 2712
System uptime: 2712.71
Got event:
Type: 1 (<class 'int'>)
Timestamp: 1970-01-01 00:45:12.700685 (<class 'datetime.datetime'>)
Got Event: RISING with timestamp: 1970-01-01 00:45:12.700685
I propose of the following fix options:
keep the timestamp attribute and change the datetime to the OS uptime in place of 1970-01-01
replace the timestamp attribute to a "since_boot_time" (or other attribute name) with only the timedelta object (and let the developper work with in his program/script)
I don't have any board to test if this issue is specific to my OPi PC2 board...
Used Versions:
gpiod: 1.5.4
Kernel: 6.1.30-sunxi64
libgpiod2: 1.6.3-1+b3
PS: I tried with the gpiomon tool to check if i got the same result: True
Hi,
I'm working on a python project on my Orange PC2 board with gpiod event on pin 40 (gpiochip1 - 199).
I got event when pin is linked to VCC (with Pull down), the event type is good but the timestamp is wrong as you can see below:
I made some tests and I don't known if there has any change made under the linux kernel but the original timestamp returned in the gpio_line_event_read_fd() function is not a timestamp but seems to be the time of the event since the OS uptime:
Got the following result:
I propose of the following fix options:
I don't have any board to test if this issue is specific to my OPi PC2 board...
Used Versions:
PS: I tried with the gpiomon tool to check if i got the same result: True
Thks
Regards,
Albin ^^
The text was updated successfully, but these errors were encountered: