PCAN message timestamps drift after macOS system sleep

Abierto
#2,092 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
68/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python
Área
embedded-iot

Línea de trabajo

Comienza en el cálculo de marcas de tiempo de PcanBus y reproduce la prueba controlada de suspensión de macOS con un adaptador PCAN. Verifica que las marcas de tiempo de los mensajes CAN recibidos sigan alineadas con la hora del reloj de pared después de reactivarse, antes del escritor BLF o del conversor CSV, y que volver a conectar el adaptador no afecte al resultado.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug
Describe the bug

On macOS, CAN message timestamps from PcanBus drift behind the current wall-clock time after the computer sleeps.
PcanBus combines the Mac boot time with a PCAN elapsed-time counter. The counter pauses while macOS sleeps, so every sleep cycle increases the timestamp error.
The incorrect timestamp is produced before BLF or CSV logging. Both log formats preserve the timestamp received from python-can.

To Reproduce
  1. Connect a PCAN adapter on macOS.
  2. Start receiving CAN messages and record their timestamps.
  3. Put the Mac to sleep, then wake it.
  4. Receive another CAN message.
  5. Compare its timestamp with the current wall-clock time.

The CAN timestamp will be behind the wall clock by approximately the amount of time the Mac spent asleep.
Unplugging and reconnecting the PCAN adapter does not reset the drift.

Expected behavior

CAN message timestamps should match the current wall-clock time after the Mac wakes from sleep.
System sleep should not cause timestamps to drift backward.

Additional context

OS and version: macOS 26.5.1, build 25F80
Python version: 3.13.14
python-can version: 4.6.1
python-can interface/s: pcan via PCAN/MacCAN
The issue has been confirmed on macOS. Potential impact on Windows has not been tested.

Traceback and logs No exception is raised. The problem appears in the timestamps assigned to received CAN messages.

During a controlled sleep test:

Wall-clock elapsed time: 73.6 seconds
PCAN elapsed counter: 60.9 seconds
Difference: 12.7 seconds
Recorded macOS sleep: 12.7 seconds

The difference between the wall clock and PCAN counter matched the macOS sleep duration.
The incorrect timestamps were present before reaching the BLF writer and CSV converter, so those components were ruled out.
Disconnecting the PCAN adapter for 60 seconds did not reset the elapsed counter or correct the timestamp.

Lenguaje dominante
Python
Estrellas
1.6k
Forks
697
Métricas de merge de PR
Sin PR fusionados en 30 d

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de hardbyte/python-can

Todos los issues de hardbyte/python-can

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.