Friday, 15 March 2013

c# - Firmata over nRF24 -



c# - Firmata over nRF24 -

i'm having technical problems... i'm trying utilize firmata arduino on nrf24, not on serial interface. have tested nrf24 communication , it's fine. have tested firmata on serial , works.

base device simple "serial relay". when has info available on serial, read , send on nrf24 network. if there info available network, read , send through serial.

node device bit complex. has custom standard firmata have added write , read override.

read override id handeled in loop method in way:

while(firmata.available()) firmata.processinput(); // handle network info , send firmata process method while(network.available()) { rf24networkheader header; uint8_t data; network.read(header, &data, sizeof(uint8_t)); serial.print(data, dec); serial.print(" "); firmata.processinputoverride(data); blinkonboard(50); } currentmillis = millis();

firmata processinputoverrride little changed method of processinput processinput reads info straight firmataserial, , in method pass info downwards method network. tested , should work fine.

write method overloaded in different way. in firmata.cpp have added method pointer can set custom method , used send info using custom method. have added custom method phone call after each of firmataserial.write() call:

firmata.h ... size_t (*firmataserialwriteoverride)(uint8_t); ... void firmataclass::printversion(void) { firmataserial.write(report_version); firmataserial.write(firmata_major_version); firmataserial.write(firmata_minor_version); firmata.firmataserialwriteoverride(report_version); firmata.firmataserialwriteoverride(firmata_major_version); firmata.firmataserialwriteoverride(firmata_minor_version); }

i have set overrided write method custom method writes byte network instead of serial.

size_t ssignal(uint8_t data) { rf24networkheader header(basedevice); network.write(header, &data, sizeof(uint8_t)); } void setup() { ... firmata.firmataserialwriteoverride = ssignal; ... }

everything seems working fine, it's info seems inverted or something. i'm using sharpduino (c#) simple digital pin toggle. here's how output looks like: (< came base, > sent base)

> 208 0 > 209 0 ... > 223 0 > 249 < 4 2 249 , here communication stops...

that lastly line came inverted. tough need invert received bytes. , worked first command. happens , communication stops again.

> 208 0 > 209 0 ... > 223 0 > 249 // study firmware version request < 249 2 4 > 240 121 247 // 240 sysex begin , 247 systex end < 240 121 < 101 0 67 0 0 1 69 0 118 < 117 0 115 0 < 0 70 0 105 0 116 0 111 0 109 < 0 97 0 < 0 109 < 116 0 97 0 247 > 240 107 247

so problem here? seems communication firmata works isn't right...

-- edit --

i solved issue. problem didn't see serial.write() calls in sysex callback. that solved, came problem... stages pass right (i guess) , dont response node when request pin states

... < f0 6a 7f 7f 7f ... 7f 0 1 2 3 4 5 6 7 8 9 b c d e f f7 // analog mapping > f0 6d 0 f7 // sysex request pin 0 state , value > f0 6d 1 f7 > f0 6d 2 f7 ... > f0 6d 45 f7 // , wait response...

there no response. ideas why happen? node receive messages correctly , code handling pin states exist.

c# serial-port arduino spi firmata

No comments:

Post a Comment