pulseIn timeout function

I have two Arduinos passing an IR signal from one to the other. I am using the pulseIn function to measure the width of the pulses to decode the information. If there is no pulse sensed by the receiver for X amount of time, (ie. blocked signal, transmitter turned off) I want the receiver to shut down the outputs it is controlling. Looking at the description for the pulseIn function, the timeout parameter only seems to apply if the pulse started and hasn't finished. I need to know how I can limit the time waiting for the pulse to start in the pulseIn function. If I can get the pulseIn instruction to return 0, the receiver can recognize that it should shut it's outputs down.

How does the RX know when a pulse is supposed to arrive?

You could try it like this: Every time you receive a pulse, you could refresh a variable, say

pulseReceivedAtMs = millis();

In the loop(), you test this

if (millis() - pulseReceivedAtMs > myTimeOutMs){
    // handle timeout

To answer the first question, about every 30ms, the transmitter sends out a 10ms pulse as a "start of transmission" signal, followed by 1ms of low, then two 1ms-2ms pulses containing the information with 1ms between them, then 1ms of low and a 5ms " end of transmission." After that, the receiver uses the information to update it's outputs and loops back to a pulseIn(2, HIGH) instruction where it waits for the next transmission. Now say the IR connection was broken. I would want that pulseIn instruction to wait 100ms for the pulse and if it doesn't come, shut down the outputs.

As for the second post, I would have done this, but as you can see, it's already pretty complicated. I was trying to use the pulseIn instruction to simplify things.

Well, if you've got as far as writing some code, then post that and maybe someone can suggest another solution.

Incidentally, you can use IR between two arduinos without explicitly handling any encoding/decoding of the signals: https://hackaday.io/project/3758-placing-two-arduinos-to-talk-to-each-other-over-ir