Giter Club home page Giter Club logo

pjon's People

Contributors

4ib3r avatar aaron-neal avatar aperepel avatar chestwood96 avatar detathome avatar drtrigon avatar eiannone avatar equinox0815 avatar esbensoeltoft avatar fabpolli avatar fredilarsen avatar gioblu avatar girgitt avatar ibantxo avatar ivankravets avatar jcallano avatar jzobac avatar matheus-garbelini avatar mauromombelli avatar michmich avatar mjasny avatar mxbranson avatar niclas-ats avatar pantonvich avatar paolop74 avatar rainerschoe avatar sticilface avatar valeros avatar willie68 avatar xlfe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pjon's Issues

Device presence confimation bit

Ciao! Its a week I am reasoning to experiment the addition of a device presence confirmation bit after the receiver device id transmission. So the receiver should set the bus HIGH only if the packet is for its ID, giving confirmation of presence on the bus to the transmitting device. This addition would add a bit of overhead per packet, but would extremely reduce the bandwidth occupation when a device is not receiving and another device is trying to communicate with it. So the bus would not be flooded by an entire packet transmitted multiple times, but by packet headers containing only the id, if you consider the a test case sending of a 50 bytes packet to a device is not receiving, it is an enormous optimization. This would expand the operational envelope in many devices / high bandwidth usage scenarios.

 ID 12              LENGTH 4         CONTENT 64       CRC 130
 ________________ _ ________________ ________________ __________________
|Sync | Byte     | |Sync | Byte     |Sync | Byte     |Sync | Byte       |
|___  |     __   | |___  |      _   |___  |  _       |___  |  _      _  |
|   | |    |  |  | |   | |     | |  |   | | | |      |   | | | |    | | |
| 1 |0|0000|11|00| | 1 |0|00000|1|00| 1 |0|0|1|000000| 1 |0|0|1|0000|1|0|
|___|_|____|__|__|_|___|_|_____|_|__|___|_|_|_|______|___|_|_|_|____|_|_|
                  |
                  |
DEVICE PRESENCE CONFIRMATION BIT

Feel free to give your feedback and considerations about it.

Not working with mega 2560

hi there, i cant get a network up and running with two uno's and one mega2560, if i use a third uno PJON works like a charm.
Maybe i found the right excuse to buy a new oscilloscope!

License

Hi,

Sorry if an issue isn't the best way to ask this, but I couldn't find any other way. Could you please specify a licence. I would really love to use this in my garage-scale (hopefully) commercial product.

Unable to receive data when interrups are being used.

Since I want to use PJON for a stepper motor project, I need to use interrups. The interrups make sure the motor runs, while the main runloop is free for other tasks (like receiving any network communication).

Unfortunately, PJON is unable to receive any messages, while the interrupts are active. If I disable the interrups, everything works fine.

Any idea how to solve this?

I'm using https://github.com/PaulStoffregen/TimerOne to configure the interrups, and run the interrupts on a 50 microsecond interval.

How to get working with ATTiny85?

I'm trying to get this working with an ATTiny85 and having problems with the Arduino IDE. I installed the ATTiny package for the Arduino IDE, but get these compiler errors:

Build options changed, rebuilding all
In file included from C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.h:33:0,

```
             from C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp:23:
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp: In member function 'boolean PJON::can_start()':

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:92:28: error: 'DDRD' was not declared in this scope

 (((P) >= 0 && (P) <= 7) ? &DDRD : (((P) >= 8 && (P) <= 13) ? &DDRB : &DDRC))

```
                        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:125:12: note: in definition of macro '**atomicWrite**'

 if ( (int)(A) < 0x40) { bitWrite(*(A), __digitalPinToBit(P), (V) );}  \

```
        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:144:88: note: in expansion of macro 'digitalPinToDDRReg'

 do {if (**builtin_constant_p(P) && __builtin_constant_p(V)) __atomicWrite**((uint8_t*) digitalPinToDDRReg(P),P,V) \

```
                                                                                    ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp:82:3: note: in expansion of macro 'pinModeFast'

   pinModeFast(_input_pin, INPUT);

   ^

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:92:71: error: 'DDRC' was not declared in this scope

 (((P) >= 0 && (P) <= 7) ? &DDRD : (((P) >= 8 && (P) <= 13) ? &DDRB : &DDRC))

```
                                                                   ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:125:12: note: in definition of macro '**atomicWrite**'

 if ( (int)(A) < 0x40) { bitWrite(*(A), __digitalPinToBit(P), (V) );}  \

```
        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:144:88: note: in expansion of macro 'digitalPinToDDRReg'

 do {if (**builtin_constant_p(P) && __builtin_constant_p(V)) __atomicWrite**((uint8_t*) digitalPinToDDRReg(P),P,V) \

```
                                                                                    ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp:82:3: note: in expansion of macro 'pinModeFast'

   pinModeFast(_input_pin, INPUT);

   ^

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp: In member function 'void PJON::send_bit(uint8_t, int)':

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:90:28: error: 'PORTD' was not declared in this scope

 (((P) >= 0 && (P) <= 7) ? &PORTD : (((P) >= 8 && (P) <= 13) ? &PORTB : &PORTC))

```
                        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:125:12: note: in definition of macro '**atomicWrite**'

 if ( (int)(A) < 0x40) { bitWrite(*(A), __digitalPinToBit(P), (V) );}  \

```
        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:137:86: note: in expansion of macro 'digitalPinToPortReg'

 if (**builtin_constant_p(P) && __builtin_constant_p(V))   __atomicWrite**((uint8_t*) digitalPinToPortReg(P),P,V) \

```
                                                                                  ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp:96:3: note: in expansion of macro 'digitalWriteFast'

   digitalWriteFast(_input_pin, VALUE);

   ^

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:90:73: error: 'PORTC' was not declared in this scope

 (((P) >= 0 && (P) <= 7) ? &PORTD : (((P) >= 8 && (P) <= 13) ? &PORTB : &PORTC))

```
                                                                     ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:125:12: note: in definition of macro '**atomicWrite**'

 if ( (int)(A) < 0x40) { bitWrite(*(A), __digitalPinToBit(P), (V) );}  \

```
        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:137:86: note: in expansion of macro 'digitalPinToPortReg'

 if (**builtin_constant_p(P) && __builtin_constant_p(V))   __atomicWrite**((uint8_t*) digitalPinToPortReg(P),P,V) \

```
                                                                                  ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp:96:3: note: in expansion of macro 'digitalWriteFast'

   digitalWriteFast(_input_pin, VALUE);

   ^

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp: In member function 'void PJON::send_byte(uint8_t)':

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:90:28: error: 'PORTD' was not declared in this scope

 (((P) >= 0 && (P) <= 7) ? &PORTD : (((P) >= 8 && (P) <= 13) ? &PORTB : &PORTC))

```
                        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:125:12: note: in definition of macro '**atomicWrite**'

 if ( (int)(A) < 0x40) { bitWrite(*(A), __digitalPinToBit(P), (V) );}  \

```
        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:137:86: note: in expansion of macro 'digitalPinToPortReg'

 if (**builtin_constant_p(P) && __builtin_constant_p(V))   __atomicWrite**((uint8_t*) digitalPinToPortReg(P),P,V) \

```
                                                                                  ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp:118:3: note: in expansion of macro 'digitalWriteFast'

   digitalWriteFast(_input_pin, HIGH);

   ^

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:90:73: error: 'PORTC' was not declared in this scope

 (((P) >= 0 && (P) <= 7) ? &PORTD : (((P) >= 8 && (P) <= 13) ? &PORTB : &PORTC))

```
                                                                     ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:125:12: note: in definition of macro '**atomicWrite**'

 if ( (int)(A) < 0x40) { bitWrite(*(A), __digitalPinToBit(P), (V) );}  \

```
        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:137:86: note: in expansion of macro 'digitalPinToPortReg'

 if (**builtin_constant_p(P) && __builtin_constant_p(V))   __atomicWrite**((uint8_t*) digitalPinToPortReg(P),P,V) \

```
                                                                                  ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp:118:3: note: in expansion of macro 'digitalWriteFast'

   digitalWriteFast(_input_pin, HIGH);

   ^

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:90:28: error: 'PORTD' was not declared in this scope

 (((P) >= 0 && (P) <= 7) ? &PORTD : (((P) >= 8 && (P) <= 13) ? &PORTB : &PORTC))

```
                        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:125:12: note: in definition of macro '**atomicWrite**'

 if ( (int)(A) < 0x40) { bitWrite(*(A), __digitalPinToBit(P), (V) );}  \

```
        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:137:86: note: in expansion of macro 'digitalPinToPortReg'

 if (**builtin_constant_p(P) && __builtin_constant_p(V))   __atomicWrite**((uint8_t*) digitalPinToPortReg(P),P,V) \

```
                                                                                  ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp:120:3: note: in expansion of macro 'digitalWriteFast'

   digitalWriteFast(_input_pin, LOW);

   ^

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:90:73: error: 'PORTC' was not declared in this scope

 (((P) >= 0 && (P) <= 7) ? &PORTD : (((P) >= 8 && (P) <= 13) ? &PORTB : &PORTC))

```
                                                                     ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:125:12: note: in definition of macro '**atomicWrite**'

 if ( (int)(A) < 0x40) { bitWrite(*(A), __digitalPinToBit(P), (V) );}  \

```
        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:137:86: note: in expansion of macro 'digitalPinToPortReg'

 if (**builtin_constant_p(P) && __builtin_constant_p(V))   __atomicWrite**((uint8_t*) digitalPinToPortReg(P),P,V) \

```
                                                                                  ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp:120:3: note: in expansion of macro 'digitalWriteFast'

   digitalWriteFast(_input_pin, LOW);

   ^

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp: In member function 'int PJON::send_string(uint8_t, char*, uint8_t)':

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:92:28: error: 'DDRD' was not declared in this scope

 (((P) >= 0 && (P) <= 7) ? &DDRD : (((P) >= 8 && (P) <= 13) ? &DDRB : &DDRC))

```
                        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:125:12: note: in definition of macro '**atomicWrite**'

 if ( (int)(A) < 0x40) { bitWrite(*(A), __digitalPinToBit(P), (V) );}  \

```
        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:144:88: note: in expansion of macro 'digitalPinToDDRReg'

 do {if (**builtin_constant_p(P) && __builtin_constant_p(V)) __atomicWrite**((uint8_t*) digitalPinToDDRReg(P),P,V) \

```
                                                                                    ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp:149:3: note: in expansion of macro 'pinModeFast'

   pinModeFast(_input_pin, OUTPUT);

   ^

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:92:71: error: 'DDRC' was not declared in this scope

 (((P) >= 0 && (P) <= 7) ? &DDRD : (((P) >= 8 && (P) <= 13) ? &DDRB : &DDRC))

```
                                                                   ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:125:12: note: in definition of macro '**atomicWrite**'

 if ( (int)(A) < 0x40) { bitWrite(*(A), __digitalPinToBit(P), (V) );}  \

```
        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:144:88: note: in expansion of macro 'digitalPinToDDRReg'

 do {if (**builtin_constant_p(P) && __builtin_constant_p(V)) __atomicWrite**((uint8_t*) digitalPinToDDRReg(P),P,V) \

```
                                                                                    ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp:149:3: note: in expansion of macro 'pinModeFast'

   pinModeFast(_input_pin, OUTPUT);

   ^

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:90:28: error: 'PORTD' was not declared in this scope

 (((P) >= 0 && (P) <= 7) ? &PORTD : (((P) >= 8 && (P) <= 13) ? &PORTB : &PORTC))

```
                        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:125:12: note: in definition of macro '**atomicWrite**'

 if ( (int)(A) < 0x40) { bitWrite(*(A), __digitalPinToBit(P), (V) );}  \

```
        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:137:86: note: in expansion of macro 'digitalPinToPortReg'

 if (**builtin_constant_p(P) && __builtin_constant_p(V))   __atomicWrite**((uint8_t*) digitalPinToPortReg(P),P,V) \

```
                                                                                  ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp:162:3: note: in expansion of macro 'digitalWriteFast'

   digitalWriteFast(_input_pin, LOW);

   ^

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:90:73: error: 'PORTC' was not declared in this scope

 (((P) >= 0 && (P) <= 7) ? &PORTD : (((P) >= 8 && (P) <= 13) ? &PORTB : &PORTC))

```
                                                                     ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:125:12: note: in definition of macro '**atomicWrite**'

 if ( (int)(A) < 0x40) { bitWrite(*(A), __digitalPinToBit(P), (V) );}  \

```
        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:137:86: note: in expansion of macro 'digitalPinToPortReg'

 if (**builtin_constant_p(P) && __builtin_constant_p(V))   __atomicWrite**((uint8_t*) digitalPinToPortReg(P),P,V) \

```
                                                                                  ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp:162:3: note: in expansion of macro 'digitalWriteFast'

   digitalWriteFast(_input_pin, LOW);

   ^

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp: In member function 'uint8_t PJON::syncronization_bit()':

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:94:28: error: 'PIND' was not declared in this scope

 (((P) >= 0 && (P) <= 7) ? &PIND : (((P) >= 8 && (P) <= 13) ? &PINB : &PINC))

```
                        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:9:33: note: in definition of macro 'BIT_READ'

 #define BIT_READ(value, bit) (((value) >> (bit)) & 0x01)

```
                             ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:162:14: note: in expansion of macro 'digitalPinToPINReg'

  ( BIT_READ(*digitalPinToPINReg(P), __digitalPinToBit(P))) ) : \

```
          ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:159:37: note: in expansion of macro '_digitalReadFast_'

  #define digitalReadFast(P) ( (int) _digitalReadFast_((P)) )

```
                                 ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp:270:23: note: in expansion of macro 'digitalReadFast'

   uint8_t bit_value = digitalReadFast(_input_pin);

```
                   ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:94:71: error: 'PINC' was not declared in this scope

 (((P) >= 0 && (P) <= 7) ? &PIND : (((P) >= 8 && (P) <= 13) ? &PINB : &PINC))

```
                                                                   ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:9:33: note: in definition of macro 'BIT_READ'

 #define BIT_READ(value, bit) (((value) >> (bit)) & 0x01)

```
                             ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:162:14: note: in expansion of macro 'digitalPinToPINReg'

  ( BIT_READ(*digitalPinToPINReg(P), __digitalPinToBit(P))) ) : \

```
          ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:159:37: note: in expansion of macro '_digitalReadFast_'

  #define digitalReadFast(P) ( (int) _digitalReadFast_((P)) )

```
                                 ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp:270:23: note: in expansion of macro 'digitalReadFast'

   uint8_t bit_value = digitalReadFast(_input_pin);

```
                   ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp: In member function 'int PJON::receive_byte()':

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:92:28: error: 'DDRD' was not declared in this scope

 (((P) >= 0 && (P) <= 7) ? &DDRD : (((P) >= 8 && (P) <= 13) ? &DDRB : &DDRC))

```
                        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:125:12: note: in definition of macro '**atomicWrite**'

 if ( (int)(A) < 0x40) { bitWrite(*(A), __digitalPinToBit(P), (V) );}  \

```
        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:144:88: note: in expansion of macro 'digitalPinToDDRReg'

 do {if (**builtin_constant_p(P) && __builtin_constant_p(V)) __atomicWrite**((uint8_t*) digitalPinToDDRReg(P),P,V) \

```
                                                                                    ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp:292:3: note: in expansion of macro 'pinModeFast'

   pinModeFast(_input_pin, INPUT);

   ^

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:92:71: error: 'DDRC' was not declared in this scope

 (((P) >= 0 && (P) <= 7) ? &DDRD : (((P) >= 8 && (P) <= 13) ? &DDRB : &DDRC))

```
                                                                   ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:125:12: note: in definition of macro '**atomicWrite**'

 if ( (int)(A) < 0x40) { bitWrite(*(A), __digitalPinToBit(P), (V) );}  \

```
        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:144:88: note: in expansion of macro 'digitalPinToDDRReg'

 do {if (**builtin_constant_p(P) && __builtin_constant_p(V)) __atomicWrite**((uint8_t*) digitalPinToDDRReg(P),P,V) \

```
                                                                                    ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp:292:3: note: in expansion of macro 'pinModeFast'

   pinModeFast(_input_pin, INPUT);

   ^

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:90:28: error: 'PORTD' was not declared in this scope

 (((P) >= 0 && (P) <= 7) ? &PORTD : (((P) >= 8 && (P) <= 13) ? &PORTB : &PORTC))

```
                        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:125:12: note: in definition of macro '**atomicWrite**'

 if ( (int)(A) < 0x40) { bitWrite(*(A), __digitalPinToBit(P), (V) );}  \

```
        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:137:86: note: in expansion of macro 'digitalPinToPortReg'

 if (**builtin_constant_p(P) && __builtin_constant_p(V))   __atomicWrite**((uint8_t*) digitalPinToPortReg(P),P,V) \

```
                                                                                  ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp:293:3: note: in expansion of macro 'digitalWriteFast'

   digitalWriteFast(_input_pin, LOW);

   ^

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:90:73: error: 'PORTC' was not declared in this scope

 (((P) >= 0 && (P) <= 7) ? &PORTD : (((P) >= 8 && (P) <= 13) ? &PORTB : &PORTC))

```
                                                                     ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:125:12: note: in definition of macro '**atomicWrite**'

 if ( (int)(A) < 0x40) { bitWrite(*(A), __digitalPinToBit(P), (V) );}  \

```
        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:137:86: note: in expansion of macro 'digitalPinToPortReg'

 if (**builtin_constant_p(P) && __builtin_constant_p(V))   __atomicWrite**((uint8_t*) digitalPinToPortReg(P),P,V) \

```
                                                                                  ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp:293:3: note: in expansion of macro 'digitalWriteFast'

   digitalWriteFast(_input_pin, LOW);

   ^

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:94:28: error: 'PIND' was not declared in this scope

 (((P) >= 0 && (P) <= 7) ? &PIND : (((P) >= 8 && (P) <= 13) ? &PINB : &PINC))

```
                        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:9:33: note: in definition of macro 'BIT_READ'

 #define BIT_READ(value, bit) (((value) >> (bit)) & 0x01)

```
                             ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:162:14: note: in expansion of macro 'digitalPinToPINReg'

  ( BIT_READ(*digitalPinToPINReg(P), __digitalPinToBit(P))) ) : \

```
          ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:159:37: note: in expansion of macro '_digitalReadFast_'

  #define digitalReadFast(P) ( (int) _digitalReadFast_((P)) )

```
                                 ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp:295:10: note: in expansion of macro 'digitalReadFast'

   while (digitalReadFast(_input_pin) && micros() - time <= BIT_SPACER);

```
      ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:94:71: error: 'PINC' was not declared in this scope

 (((P) >= 0 && (P) <= 7) ? &PIND : (((P) >= 8 && (P) <= 13) ? &PINB : &PINC))

```
                                                                   ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:9:33: note: in definition of macro 'BIT_READ'

 #define BIT_READ(value, bit) (((value) >> (bit)) & 0x01)

```
                             ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:162:14: note: in expansion of macro 'digitalPinToPINReg'

  ( BIT_READ(*digitalPinToPINReg(P), __digitalPinToBit(P))) ) : \

```
          ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:159:37: note: in expansion of macro '_digitalReadFast_'

  #define digitalReadFast(P) ( (int) _digitalReadFast_((P)) )

```
                                 ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp:295:10: note: in expansion of macro 'digitalReadFast'

   while (digitalReadFast(_input_pin) && micros() - time <= BIT_SPACER);

```
      ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp: In member function 'uint8_t PJON::read_byte()':

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:94:28: error: 'PIND' was not declared in this scope

 (((P) >= 0 && (P) <= 7) ? &PIND : (((P) >= 8 && (P) <= 13) ? &PINB : &PINC))

```
                        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:9:33: note: in definition of macro 'BIT_READ'

 #define BIT_READ(value, bit) (((value) >> (bit)) & 0x01)

```
                             ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:162:14: note: in expansion of macro 'digitalPinToPINReg'

  ( BIT_READ(*digitalPinToPINReg(P), __digitalPinToBit(P))) ) : \

```
          ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:159:37: note: in expansion of macro '_digitalReadFast_'

  #define digitalReadFast(P) ( (int) _digitalReadFast_((P)) )

```
                                 ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp:311:19: note: in expansion of macro 'digitalReadFast'

```
 byte_value += digitalReadFast(_input_pin) << i;

               ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:94:71: error: 'PINC' was not declared in this scope

 (((P) >= 0 && (P) <= 7) ? &PIND : (((P) >= 8 && (P) <= 13) ? &PINB : &PINC))

```
                                                                   ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:9:33: note: in definition of macro 'BIT_READ'

 #define BIT_READ(value, bit) (((value) >> (bit)) & 0x01)

```
                             ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:162:14: note: in expansion of macro 'digitalPinToPINReg'

  ( BIT_READ(*digitalPinToPINReg(P), __digitalPinToBit(P))) ) : \

```
          ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:159:37: note: in expansion of macro '_digitalReadFast_'

  #define digitalReadFast(P) ( (int) _digitalReadFast_((P)) )

```
                                 ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp:311:19: note: in expansion of macro 'digitalReadFast'

```
 byte_value += digitalReadFast(_input_pin) << i;

               ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp: In member function 'int PJON::receive()':

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:92:28: error: 'DDRD' was not declared in this scope

 (((P) >= 0 && (P) <= 7) ? &DDRD : (((P) >= 8 && (P) <= 13) ? &DDRB : &DDRC))

```
                        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:125:12: note: in definition of macro '**atomicWrite**'

 if ( (int)(A) < 0x40) { bitWrite(*(A), __digitalPinToBit(P), (V) );}  \

```
        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:144:88: note: in expansion of macro 'digitalPinToDDRReg'

 do {if (**builtin_constant_p(P) && __builtin_constant_p(V)) __atomicWrite**((uint8_t*) digitalPinToDDRReg(P),P,V) \

```
                                                                                    ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp:340:3: note: in expansion of macro 'pinModeFast'

   pinModeFast(_input_pin, OUTPUT);

   ^

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:92:71: error: 'DDRC' was not declared in this scope

 (((P) >= 0 && (P) <= 7) ? &DDRD : (((P) >= 8 && (P) <= 13) ? &DDRB : &DDRC))

```
                                                                   ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:125:12: note: in definition of macro '**atomicWrite**'

 if ( (int)(A) < 0x40) { bitWrite(*(A), __digitalPinToBit(P), (V) );}  \

```
        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:144:88: note: in expansion of macro 'digitalPinToDDRReg'

 do {if (**builtin_constant_p(P) && __builtin_constant_p(V)) __atomicWrite**((uint8_t*) digitalPinToDDRReg(P),P,V) \

```
                                                                                    ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp:340:3: note: in expansion of macro 'pinModeFast'

   pinModeFast(_input_pin, OUTPUT);

   ^

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:90:28: error: 'PORTD' was not declared in this scope

 (((P) >= 0 && (P) <= 7) ? &PORTD : (((P) >= 8 && (P) <= 13) ? &PORTB : &PORTC))

```
                        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:125:12: note: in definition of macro '**atomicWrite**'

 if ( (int)(A) < 0x40) { bitWrite(*(A), __digitalPinToBit(P), (V) );}  \

```
        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:137:86: note: in expansion of macro 'digitalPinToPortReg'

 if (**builtin_constant_p(P) && __builtin_constant_p(V))   __atomicWrite**((uint8_t*) digitalPinToPortReg(P),P,V) \

```
                                                                                  ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp:345:7: note: in expansion of macro 'digitalWriteFast'

```
   digitalWriteFast(_input_pin, LOW);

   ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:90:73: error: 'PORTC' was not declared in this scope

 (((P) >= 0 && (P) <= 7) ? &PORTD : (((P) >= 8 && (P) <= 13) ? &PORTB : &PORTC))

```
                                                                     ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:125:12: note: in definition of macro '**atomicWrite**'

 if ( (int)(A) < 0x40) { bitWrite(*(A), __digitalPinToBit(P), (V) );}  \

```
        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:137:86: note: in expansion of macro 'digitalPinToPortReg'

 if (**builtin_constant_p(P) && __builtin_constant_p(V))   __atomicWrite**((uint8_t*) digitalPinToPortReg(P),P,V) \

```
                                                                                  ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp:345:7: note: in expansion of macro 'digitalWriteFast'

```
   digitalWriteFast(_input_pin, LOW);

   ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:90:28: error: 'PORTD' was not declared in this scope

 (((P) >= 0 && (P) <= 7) ? &PORTD : (((P) >= 8 && (P) <= 13) ? &PORTB : &PORTC))

```
                        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:125:12: note: in definition of macro '**atomicWrite**'

 if ( (int)(A) < 0x40) { bitWrite(*(A), __digitalPinToBit(P), (V) );}  \

```
        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:137:86: note: in expansion of macro 'digitalPinToPortReg'

 if (**builtin_constant_p(P) && __builtin_constant_p(V))   __atomicWrite**((uint8_t*) digitalPinToPortReg(P),P,V) \

```
                                                                                  ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp:351:7: note: in expansion of macro 'digitalWriteFast'

```
   digitalWriteFast(_input_pin, LOW);

   ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:90:73: error: 'PORTC' was not declared in this scope

 (((P) >= 0 && (P) <= 7) ? &PORTD : (((P) >= 8 && (P) <= 13) ? &PORTB : &PORTC))

```
                                                                     ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:125:12: note: in definition of macro '**atomicWrite**'

 if ( (int)(A) < 0x40) { bitWrite(*(A), __digitalPinToBit(P), (V) );}  \

```
        ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\includes/digitalWriteFast.h:137:86: note: in expansion of macro 'digitalPinToPortReg'

 if (**builtin_constant_p(P) && __builtin_constant_p(V))   __atomicWrite**((uint8_t*) digitalPinToPortReg(P),P,V) \

```
                                                                                  ^
```

C:\Users\Jordan\Documents\Arduino\libraries\PJON\PJON.cpp:351:7: note: in expansion of macro 'digitalWriteFast'

```
   digitalWriteFast(_input_pin, LOW);

   ^
```

exit status 1
Error compiling.

Auto addressing sometimes finds duplicate addresses

The ARP implementation sometimes finds duplicate addresses.
Tested with 5 slave Arduinos (Pro Mini) reporting their address to a master.

I rolled my own ARP for a project – the way I implement it is having all slaves send their randomly generated address to a master, along with a UID (randomly generated 32-bit integer). The master just looks for duplicate addresses if any, and sends a new address to the duplicate devices along with the UID. The slave with the corresponding UID will be set to the new address. This works because the slaves have to talk to a master device which handles the addresses. Having a robust ARP independent of a master device with PJON is perhaps non trivial to do.

SendAndReceive example fails with OverSampling via wireless

Using PJON 3.0 beta as of 2016-05-13.

To me it seems that sending messages in both directions like this works over a wire but not wirelessly.

Having set up two Arduino Unos with a wireless sender+receiver each, I have changed some of the examples from using SoftwareBitBang to OverSampling, and changing set_pin(12) to set_pins(6,7). The SpeedTest and NetworkAnalysis samples work perfectly over the wireless connection.

But I need something similar to the SendAndReceive example, and this will not work with OverSampling and the wireless connection. With the original example and a wire between pin 12 on each Arduino, it works.

The fact that SpeedTest and NetworkAnalysis works fine indicates that my hardware setup is fine. I can also switch which board is Device1.ino and Device2.ino and this also works perfectly.

I have attached the modified example files. The receiver is connected to pin 6 and the transmitter to pin 7 on each of the two Arduinos.

SendAndReceive_wireless.zip

license

Is the Stipulation about advertising materials compliant with common Open Source license requirements?
Or is this not meant to be strictly speaking Open Source software?

The section I could see being violated is "1. Free Redistribution" because requiring the ad-note could be interpreted as payment of sort.

I don't feel comfortable to say that this is certainly a problem, and I would be glad if a person more competent in these matters could weigh in here.

In any case, your protocol is fantastic 👍 and I'm glad someone has liberated the space of one-wire-ish protocols. I also felt uncomfortable using the dallas one-wire stuff...

Also mad props for the nice and clear writeup of the protocol in the wiki! Well done, sir! 🎉

Better CRC or Starting Symbol?

Currently, the CRC doesn't take the position of a byte into account. This can lead to problems when bytes are missing (e.g. when a device starts to read the stream at an unknown time and misses the first few bytes). I used my little app to test messages with 5 bytes of content (8 bytes in total). With the current CRC calculation method there are a lot of potential issues (and I mean A LOT if one uses more than one device).

Example: The message 3-8-2-6-4-15-13-9 could be received by a device with the id 6 as 6-4-15-13. The CRC is correct, the device sends a faulty ACK, and the device 3 gets a wrong message because two bytes are sent over the channel at the same time.

The CRC calculation needs to be very simple, I guess. Any ideas?

MSB/LSB switch?

Hi, I spent some time debugging the physical comms on the wire, and saw that current PJON version uses LSB-first mode. This is quite inconvenient when looking at signals and trying to make sense of them. Was it done for some performance reasons? If not, does it make sense to add the MSB/LSB option and leave LSB the default?

¿Used with RF link?

¿utilizable con link RF?
I can use it with a single RF module or only cable?
You can comment more about of medium of transportation?

Documentation request: Sending arbitrary values.

While the documentation clearly describes on how to send short commands, it isn't completely clear how to send arbitrary values. For example, if we want to expand the blink example, by adding the blink speed to the message, how should this be done?

It would be great if a short command could contain an addition payload which would be used as a paramater to the reaction method.

For example:

Sender:

void loop() {
   int blink_send = network.send_short_command(100, 'B', '200');
   delay(1000);
}

Receiver:

void setup() {
 network.insert_reaction('B', led_blink);
};

void led_blink(char *payload) {
 int speed = atoi( payload );  //char * to int conversion

 digitalWrite(13, HIGH);
 delay(speed);
 digitalWrite(13, LOW);
};

void loop() {
 network.receive(1000);
};

Or is there currently a better way to do this?

Timing in a separate file

Ciao! I am considering to move timing values in a new file Timing.h to have a dedicated space for that and to mantain clarity and add practical space for useful comments. Let me know what you think about it.

Receiving wrong data, etc.

Hi! I have a lot of issues right now. My head is a bit spinning as I was working on this the whole day. Maybe I miss something important. Anyway, I thought I should ask you before I continue with debugging. Hope you can help me.

My setup consists of two Unos and one Nano. When I start my software (a small C# tool) it connects to one of the two Unos ("master", e.g. device id 1) via USB. Then, the Uno sends a "ping" message to the devices 2, 3, 4, 5, and 6 (= "slaves"). The two other devices should then respond with a "I'm alive" message while the non-existing devices 4, 5, and 6 should raise a CONNECTION_LOST error. This usually works perfectly fine but not always.

In a few cases the Nano seems to respond, but the master device doesn't care (receiver function is not called). I started to debug this case. The Nano definitely gets an ACK and removes the package from the queue. I'm not sure if the ACK was sent by the master device or by something else, though.

When I fiddled around to find the cause, "device 4" suddenly stopped raising a CONNECTION_LOST error. I found out that my second Uno was responding to the ping message with ACK although its device id is 3. I removed the Nano to simplify the whole system and added more Serial.print() stuff in your code to see what is being sent and what is being received.

Master sends (this->send_byte is called with these values):

3-4-3-4 // ping for device 3
4-4-3-3 // ping for device 4

Slave receives (this->receive_byte() returns these values):

3-3-0-0 // incorrect!
3-4-0-0 // incorrect!
3-4-0-0 // incorrect!
3-4-3-4 // correct!

This is what happens with the original PJON.cpp. As I said in my last issue, I need to include the sender id. Therefore, I have changed a few parts of your code so the sender id is always included as the first byte of the content. In this case, the messages look like this:

Master sends (this->send_byte is called with these values):

3-5-1-3-4 // ping for device 3
4-5-1-3-3 // ping for device 4

Slave receives (this->receive_byte() returns these values):

3-5-1-3-4 // correct!
3-3-0-0-4 // incorrect!

I have no idea what's happening. Maybe I changed something, I shouldn't have changed, something is interfering, the timings are incorrect, or something is being converted wrongly. I hope my explanations are clear. If you need more information feel free to ask. Any help is appreciated!

ATtiny841 and ATtiny1634 Support

I have been able to make this library work (well, the Blink Transmit/Receive examples) on the ATtiny841 (core from https://github.com/SpenceKonde/arduino-tiny-841) by adding AVR_ATtiny841 to the list of Tiny chips.
DigitalWriteFast.h needs some updates as well, but they are over my head (I just reverted back to DigitalWrite in setup to get Blink to work).

It looks like adding 1634 support should be pretty similar. I don't have one of those soldered up yet to test on but it did compile.

I have both chips and can do whatever further testing is needed.

On a happy note, this library is pretty exciting! I have been trying to get OneWire to work between an ESP-03 and a Tiny841 for a while now, and this worked the first try. Good stuff!

Thanks!

Benefits over i2c

Frist of: awesome work. Very impressed with the concept and final product. I'm temped to use it in my current project: 4 automatic curtains controlled by one master Arduino or ESP8266.

Before I do, I would like to know the benefits over using i2c. Is this something you can elaborate on? (Maybe even put it in the Readme doc?)

Thanks for your work. Cheers!

Is it possible to get the sender id?

Hi gioblu,

very nice library! I have a question, though. Is there a possibility to get the sender id of a package? I saw that the set_receiver function's comment had a param for this in an older version. I guess this has never been implemented, has it? Should I send the sender id as part of the content?

Best,
Fabian

Wiring Diagram ESP8266 - Arduino

Since PJON is now compatible with the ESP8266 (which is a 3v3 device), it might be helpful to supply a wiring diagram in the readme on how to connect a 3v3 device (ESP8266) to an 5v device (Arduino).

Keep up the good work!

ARM compatibility

It would be terrific if this library could run on Due and Zero boards.
Thanks

Unable to send zero.

I'm trying to send a byte value as a payload. Any value works, except 0. A zero won't be broadcasted (checked it with a scope.)

Works:

network.send(1, 1, 1);
network.send(1, 2, 1);
network.send(1, 3, 1);
...
network.send(1, 255, 1);

Doesn't work:

network.send(1, 0, 1);

PJON Protocol Analyzer

Hi guys,

I've been busy hacking recently (well, scratching my own itch), and brought a custom protocol analyzer for Saleae Logic to a usable state: https://github.com/aperepel/saleae-pjon-protocol-analyzer

It doesn't yet understand multi-byte payloads (will come next, so for now don't send more than a 1 byte payload :) ). It can do a lot already, and I figured I'd put it in front of people sooner rather than later:

https://github.com/aperepel/saleae-pjon-protocol-analyzer/releases

Happy hacking!

Issues with big packets

I'm sorry for the long delay in my response. I hadn't had the time to test everything until this week. Fortunately, after a lot of testing, I can say it is very stable now when sending short messages. I haven't noticed any more problems so far. I added two more bytes to my messages (a total of 4 bytes now) to be more stable in general, though.

After the problems with small packets, however, I have now problems with big packets (e.g. 50 bytes or more) :-) The problem is not the message's size itself, though. There must be another bug in the receive function. The problem might be that the CRC could be correct although the message isn't.

1.) When PACKET_MAX_LENGTH (e.g. = 50) was lower than the actual size of the received package (e.g. = 60), the first strange thing happened. The sender tried to send the message over and over again but failed with 256 (FAIL). The receiver, however, received the message and instead of declining it, this->_receiver() was called with the data of the last correct message (e.g. the last short message). Long story short, with every FAIL at the sender, I got the same old message at the receiver.

2.) I have to send about 30 packets with a size of about 250 bytes each. As this didn't work very well, I added an id to the messages to see if the order was correct and if all packets were received correctly. I was very surprised when I checked the ids in my receiver function:

0, 0, 1, 2, 3, 4, 5, 5, 8, 9, 10, ...

So, in some cases I recevied the same package twice (while the sender failed with 256). In other cases, I didn't receive the package at all (while the sender reported ACK). It was definitely better after I changed if(!CRC) { to if(!CRC && (package_length > 4)) { in your library to ensure that the package might be correct.

My assumption is that there are cases where the loop breaks after one or two bytes (because package_length is 1 or 2 or something) but the CRC is still correct. Then it calls this->_receiver() with old data (data is never set back to null, is it?) and sends ACK. If the sender is still sending then it doesn't notice the ACK, fails with 256 and resends the package. Could this be the cause? Any ideas how to fix that? I have no idea why some messages are skipped, though. Could be the same reason: ACK when there shouldn't be an ACK.

I have no problem with the fact that big packets might cause a lot of trouble (several FAILs before ACK, interference, etc.) but the fact that the library seems to behave unexpected is the main problem in this case. It works if I send the data splitted into very small packets but that makes it slower. Any idea?

Thanks!

P.S.: As promised I will also reply to your e-mail in the next few days.

A single Sketch being a Transmitter and Reciever....

I tried putting together a sketch that both transmits and receives; and it doesn't seem to work.

PJON pjonNet(PjonPin, PjonUnitId); 

void OnReceive(uint8_t size, uint8_t* payload)  {
// left out code as all it did was echo it to serial
}
void setup() {
pjonNet.set_receiver(OnReceive);
}

void loop() {
pjonNet.update();
pjonNet.receive();
// left out code that all it did was buffer serial input if there was any call pjonNet.send_string() when last char was a '\r'
}

I confirmed the wiring works with your example, but I could not find an example that could be both a sender and receiver.

extend range with rs485?

my installation it is very extensive. I'm about to try using PJON as protocol, but using rs485 like interface.
Analyzing the code I see very optimal to send commands as I need.
I'm trying to control remotely access a door, which sent a command it must receive a state when someone accesses through a RDIF tag.

I have some questions:

The master (data collector) should send commands long variables.
Example: open, 1 character
Add a tag, 10 characters

  1. Can handle variable data, or should I define a maximum?
  2. In the begin () function use analogRead can cause problems if this pin is used as part of the program to another function as a digital pin.
  3. What happens if I try to access beyond the long, assuming that the data entered and which I hope is not?

Infinite collision

As came out from tests made by Mauro and from suggestions made by the community on the hackaday post, there is a bug. If we code in the same way many devices and they start at the same time, for example, because of a common power supply, they will likely all collide and in the same way execute quadratic backoff always colliding or finding the channel BUSY.

So I see 2 possible cases (both leads to collision loop):

  • Startup collision
  • Casual collision

On transmitter side:

  • Add initial random delay on device init (to avoid startup collision)
  • Add random delay if NAK (to avoid casual collision)
  • Add a random delay if FAIL (to avoid casual collision)

Please feel free to share your point / suggest

Raspberry PI compatibility

Ciao! I am considering which is the best and most efficient approach to implement the PJON standard on Raspberry. Do you have some suggestion? I sincerely would remain on C / C++ / Wiring.

Physical layer strategies

Hi there. Is long time I am considering to give the chance to the user to develop its own strategy for data transmission and reception, and so enable to switch the low level functions needed to physically receive and transmit data. This would give the chance to the user to port different communication media like Infrared / visible light, radio waves (see PJON_ASK) and obviously one or more conductive elements.

I personally developed 3 strategies in my experimentations:

  1. Digital bit centered single sample (very effective on wires / conductive elements)
  2. Analog read oversampling (quite effective used with infrared light)
  3. Digital pseudo-oversampling (quite effective on noisy wires and radio)

Would be amazing to have the chance to select on instantiation which strategy is more effective with the communication medium used.

Obviously:

  • PJON_ASK low level functions would be integrated in the PJON repository as a Strategy
  • Timing.h would be definetly more complicated (3 timing setups per strategy)
  • Maybe will be difficult to constrain data rate without excluding some use-cases.

Can I mess with MAX_PACKETS and PACKET_MAX_LENGTH?

In order to free some memory, I see that reducing MAX_PACKETS and PACKET_MAX_LENGTH helps a lot.
Do their value depend on the length of the packets I send? I'm for example never sending packets larger than two bytes.
What should I consider if I want to reduce those values?
Thanks.

easy function to send Integers

Hi,
is there a easy function to send and receive a integer value (8,16 or 32 bit). I think, this is the most payload. And its easier to handle than a string of chars.
And in combination with the sender_id as a content_id it would be more awesome. So i can send one command to all devices.

Bootloader to program a device through PJON

Ciao! I am a while thinking about this. Would be amazing to ble able to code any device on a PJON bus, through PJON and the bus itself using a dedicated bootloader. Obviously I would start with Arduino Duemilanove.

Latency amount?

I didn't see any obvious answer, but what is the expected latency of this protocol and maximum latency? Going just from the speed of compatibility mode, I get 1.8ms to send a byte.. but I'm pretty sure that's not the right way to figure out latency, especially maximum latency with error correction and such

Add an option to invert the 0/1 logic so we can use internal pull-up resistors

Hi, I was getting frustrated not able to make basics work, but was finally able to dig up that bit in a troubleshooting guide about a 'Busy' signal and, after adding a 10K pull-down resistor, everything worked. I, however, see couple problems with a pull-down resistor requirement:

  1. It's an external component. If we are going for simplicity, not the right direction.
  2. Most Arduino/Wiring-compatible boards have only pullup resistors (unlike Mega, MBed, etc.). Can we use that instead. The only change required is to invert the logic for reading 1 and 0, if I understand things correctly.

We could e.g. have an overloaded constructor taking an optional pullup flag (defaulting to false).

How to Deal with interference (wiki)

I understand that just connect 1 Data Cable works, but is there you got previous care, pullup resistors, diodes protection?
No it is not clear how protect in a noisy environment or outdoor use.
Can add this to wiki?

Use of interrupts?

I completely understand your desire to implement this entirely in software. This is more of a theory question. I have not tried to implement it yet as I've not got pjon working on ESP8266 just yet! but here goes..

The ESP8266 wifi has to be serviced every so often, otherwise you get a crash. polling a pin for 1ms constantly is not the 'most' efficient thing to do, and would hold up wifi. Is there any reason why I can't put the

network.receive(1000);

receive function inside a call back, and say set the timeout to 1? Would this in theory still work?

This lib looks wicked! and works very well on arduino so thumbs up.

cheers

A

STM32F103R

Hi there :)
Been trying to compile this library on a STMF103RB, ARM Cortex-M3 MCU,
http://www2.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32f1-series/stm32f103/stm32f103rb.html
similar to the teensy, due. Better known on the http://www.stm32duino.com/ site as the "blue pill"
unfortunately it doesn't compile. It does compile on the ESP8266 12F that I am trying to get to talk to each other.
it complains

'BIT_WIDTH' , 'READ_DELAY', 'BIT_SPACER' 'ACCEPTANCE', "was not declared in this scope"<
i'm guessing that it needs an entry in the timing.h so how to work out those values?

One more thought:
Packet length is fixed at uint8_t , and sending binary data seems to be pretty difficult.
I can understand breaking up a frame of data into 256 byte so as not tie up the bus. Since the datalength has to be stipulated with the data, are there any thoughts to increase the data length size, and/or something to break up large Frames of data into smaller packets with re-assembly?

Raj

Feature request: Add Multicast

Like /u/kloptopsmentions on Reddit, it might be a good idea to implement multicasting.

Maybe sending to ID 0 or 254 would broadcast the message to all devices? You could use this for auto discovery of devices (like ZeroConf). Maybe even allow a way of auto assigning of ID's.

Modifications to support interrupt-driven strategies

Ciao! I am still testing 3.0-beta but already considering which modifications are necessary to have a nominal functionality with a strategy using an interrupt driven procedure. The first thing came out speaking with a friend is the necessity of the SENDING state for the packets where interrupt calls are already attached. Feel free to share you consideration.

Phantom device (change BROADCAST ID)

Two Arduino pro mini ATmega328.
A master set at address 45 and a slave set at 44.
Bus on pin 12.

While sending to device 124 even though it didn't exist on the network, I get ACK values back.

Can someone reproduce this?

Here, I wrote a script to check for a response on all addresses.
Code for master:

#include <PJON.h>

PJON network(12, 45);

char content[] = "ajtyenflhiehfnvk";

void setup() {
    Serial.begin(115200);
    delay(250);
    uint8_t test = 0;
    long scan_time;

    for (int i=0; i<256; i++) {
        scan_time = millis();
        while (millis() - scan_time < 20) {
        int response = network.send_string(i, content, 16);
            if (response == ACK) {
                test++;
            }
        }
    if (test > 0) Serial.println(i);        
    test = 0;
    }
}

void loop() {};

Code for slave:

#include <PJON.h>

PJON network(12, 44);

void setup() {
  Serial.begin(115200);
};

void loop() {
  network.receive(); 
};

Arduino -> ESP8266 communication.

I've been struggling with this for a whole day, and I'm not sure what to do.

Logic is working. See osillyscope, correct signals, correct voltages. I've got 2 arduino nano's communicating. One using BROADCAST, the other receiving. Using STANDARD mode. ESP8266 is 80Mhz. If I write a sketch that attaches an interrupt it detects the pulses.. and seems like the correct timing... but I have no debug info in PJON to work out why it is not detecting the pulses. I get nothing in a the message callback, and no errors either.

pjon-signal-5v-3v
screen shot 2016-04-18 at 22 54 46
screen shot 2016-04-18 at 22 56 35

Any help appreciated. It looks like the initial low pulse might be a bit long from the arudino... 400us. but I'm really not sure.

It's XOR based error detection, not CRC

What you are implementing is a simple parity scheme. Please don't call it a CRC. In any case, there is plenty of spare cycles to implement CRC8 if all you want to use is eight bits.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.