I2C and Token ring - a new hope.

Noted a previous post relating to I2C and token ring but no significant updates.
So after experiencing the the issue on a small 3 device bus myself, I decided I wanted each device to be a master - but ran into the inherent problem in I1C networking where 2 devices wishing to transmit at the same time could lock the bus.

I came up with a simple token ring solution which is almost working - only started on this a week ago and have almost completed the code.

1: All devices are given a device code which it uses to identify itself on the network [base address plus offset]. This also acts as a unique delay should the ring be broken.

2: All devices can receive so can accept a message and create a token and therefore will not clash.

3: Lowest id device starts by creating a blank token and holds it for a short delay pending any transmissions. It then passes it to the next device.

4: A ring timeout occurs if waiting for its return is exceeded.

5: Any device which has received a message or token can transmit and then drops token. Device receiving message acts on it if required and passes token to next device in ring if no transmission required.

6: Should a device go down or bus is disconnected from a device, timeouts occur and the ring direction is reversed. Code snippets in various reception and transmission routines monitor ring direction and timeouts and set flags accordingly

7: This code is just being finallised but all indications are that it is almost working.

8: I would ultimely see this going into a library as the code is somewhat fragmented at this time so a library would seem to be the way to go.

I will update this post if there is any further interest but please be patient as I am not a seasoned coder and am really strugling at times with some of the dreaded C++ syntax.

regards Colin :slight_smile: