I am trying to run an RPC that sends a serial command to a USB device at a specific timestamp. However, it seems that the RPC actually runs roughly immediately when the code is run, instead of after kernel delays, etc.

@kernel
def run(self):
    self.core.reset()
    self.ttl.pulse(1.e-6)
    delay(1.)
    self.serial() # my rpc

I see the effect of the serial communication roughly 1ms after the ttl pulse, instead of the 1 second delay I want. Is there a straightforward way to get the rpc to execute wrt the position of the timeline cursor, instead of whenever the core device reaches the rpc while scheduling things into the FIFO?

Got some help -- I can enforce RPC execution timestamp with artiq.coredevice.core.wait_until_mu(). One just needs to adjust the timestamp with a delay afterward to avoid RTIOUnderflows, since you've just eaten all your slack with wait_until_mu(). This means that if you want something to happen during that delay, you'd have had to schedule it before the call to wait_until_mu() so that it gets into the FIFO before you eat the slack.