- 
                Notifications
    You must be signed in to change notification settings 
- Fork 20
Description
Problem description
The functions
hal.initializeNotifier
hal.setNotifierName
hal.updateNotifierAlarm
hal.waitForNotifierAlarm
all return non-zero status in python, while similar c++ code returns 0 status.
e.g.:
        self.notifier, status1 = initializeNotifier()
        status2 = setNotifierName(self.notifier, "TimedRobot")
        status3 = updateNotifierAlarm(self.notifier, startTime+100000)
        now_us, status4 = waitForNotifierAlarm(self.notifier)
See https://github.com/MikeStitt/pythonExperiments/tree/mostrobotpy-issue-165-20250423/cppRobot/robot for minimal c++ code to show that c++ does not have the issue.
See https://github.com/MikeStitt/pythonExperiments/tree/mostrobotpy-issue-165-20250423/pythonRobot for minimal python code to recreate the issue.
The c++ simulation output is:
HAL_InitializeNotifier  : Notifier: 50331649 status=0
HAL_SetNotifierName     : Notifier: 50331649 status=0
HAL_UpdateNotifierAlarm : Notifier: 50331649 status=0
HAL_WaitForNotifierAlarm: Notifier: 50331649 status=0
GetFPGATime: startTime=892695 now_us=997708 endTime=997710
The program '/Users/mikestitt/Documents/first/pythonExperiments/cppRobot/robot/build/install/frcUserProgram/osxuniversal/debug/lib/frcUserProgram' has exited with code 0 (0x00000000).
The python simulation output is:
 robotpy sim 
14:43:32:899 INFO    : faulthandler        : registered SIGUSR2 for PID 98761
14:43:32:900 INFO    : halsim_gui          : WPILib HAL Simulation 2025.3.2.0
HAL Extensions: Attempting to load: libhalsim_gui
Simulator GUI Initializing.
2025-04-23 14:43:32.960 Python[98761:7908457] WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES.
Simulator GUI Initialized!
HAL Extensions: Successfully loaded extension
14:43:33:002 WARNING : pyfrc.physics       : Cannot enable physics support, /Users/mikestitt/Documents/first/pythonExperiments/pythonRobot/physics.py not found
14:43:33:002 INFO    : wpilib              : RobotPy version 2025.3.2.0
14:43:33:002 INFO    : wpilib              : WPILib version 2025.3.2.0
14:43:33:002 INFO    : wpilib              : Running with simulated HAL.
14:43:33:006 INFO    : nt                  : Listening on NT3 port 1735, NT4 port 5810
Not loading CameraServerShared
********** Robot program startup complete **********
HAL_InitializeNotifier  : Notifier: 50331649 status=0x2a2f2805
HAL_SetNotifierName     : Notifier: 50331649 status=0x00000001
HAL_UpdateNotifierAlarm : Notifier: 50331649 status=0x2a2f2805
HAL_WaitForNotifierAlarm: Notifier: 50331649 status=0x375d8001
GetFPGATime: startTime=356113 now_us=461130 endTime=461185
14:43:33:125 WARNING : your.robot          : Unexpected return from startCompetition() method.
For the c++ code see: https://github.com/MikeStitt/pythonExperiments/blob/mostrobotpy-issue-165-20250423/cppRobot/robot/src/main/cpp/ExpTimedRobot.cpp#L33
For the python code see: https://github.com/MikeStitt/pythonExperiments/blob/mostrobotpy-issue-165-20250423/pythonRobot/exptimedrobotpy.py#L27
Operating System
MacOS
Installed Python Packages
Reproducible example code
from wpilib import IterativeRobotBase
import hal
from hal import initializeNotifier, setNotifierName, observeUserProgramStarting, updateNotifierAlarm, \
    waitForNotifierAlarm
from wpilib import RobotController
class ExpTimedRobotPy(IterativeRobotBase):
    def __init__(self, periodS: float = 0.020):  # todo are the units on period correct?
        super().__init__(periodS)
    def startCompetition(self) -> None:
        self.robotInit()
        if self.isSimulation():
            self._simulationInit()
        # Tell the DS that the robot is ready to be enabled
        print("********** Robot program startup complete **********")
        observeUserProgramStarting()
        startTime = RobotController.getFPGATime()
        status1 = 0
        status2 = 0
        status3 = 0
        status4 = 0
        self.notifier, status1 = initializeNotifier()
        status2 = setNotifierName(self.notifier, "TimedRobot")
        status3 = updateNotifierAlarm(self.notifier, startTime+100000)
        now_us, status4 = waitForNotifierAlarm(self.notifier)
        endTime = RobotController.getFPGATime()
        print(f"HAL_InitializeNotifier  : Notifier: {self.notifier} status=0x{status1&0xFFFFFFFF :08x}")
        print(f"HAL_SetNotifierName     : Notifier: {self.notifier} status=0x{status2&0xFFFFFFFF :08x}")
        print(f"HAL_UpdateNotifierAlarm : Notifier: {self.notifier} status=0x{status3&0xFFFFFFFF :08x}")
        print(f"HAL_WaitForNotifierAlarm: Notifier: {self.notifier} status=0x{status4&0xFFFFFFFF :08x}")
        print(f"GetFPGATime: startTime={startTime} now_us={now_us} endTime={endTime}")
    def endCompetition(self):
        hal.stopNotifier(self.notifier)