I am trying to impliment a multimaster situation where the code will do one with when my other device is on and functioning, or do another when it is either off or disconnected.
My situation, needs two devices in to different locations (which are communicating via I2C over 4 fiber optic cables.)
Each has the ability to set and read states of push button switches and update a read out, as well as the solenoid valves they are each connected to.
This aspect works flawlesly.
The issue at hand, is running code which only runs when an I2C device is detected.
In the I2c scanner code, error = wire.endTransmission() ends on its own if no device was detected (ie my other arduino is powered off) and the loop keeps going.
Now when I try to use the error codes essentially If error does not equal 0 no device is connected dont do stuff If it does equal 0 then a device is connected and send the data before ending.
the issue comes into play when a device is not connected, with the I2C Scanner code placed into my code it freezes on End Transmission, While the I2c scanner code working on its own does not freeze.
I suppose a solution here, could be to just add two more fibers with constant light sources and detect them using some of my other I/O pins. But id rather not nee 6 fibes.
This is not what multimaster means. It's just having two masters on the same bus which are sometimes sending some data. What happens if both masters start sending at the same time? If you can live with these race conditions this may be fine for you but it's not what I2C multimaster means.
ends on its own if no device was detected (ie my other arduino is powered off) and the loop keeps going.
Powered down is not the same as not connected. How have you wired the two Arduinos? Do you have schematics of your setup? How do the I2C signals translate to your fiber signals? Do you use hardware that knows the I2C protocol and translates that correctly into optical signals? How does that work with clock stretching?
How did you find out where the code freezes?