1
$\begingroup$

I'm having some technical problems... I'm trying to use Firmata for arduino but over nrf24, not over Serial interface. I have tested nRF24 communication and it's fine. I have also tested Firmata over Serial and it works.

Base device is simple "serial relay". When it has data available on Serial, read it and send it over nRF24 network. If there is data available from network, read it and send it through Serial.

Node device is a bit complex. It has custom Standard Firmata where I have just added write and read override.

Diagram

Read override id handeled in loop method in this way:

while(Firmata.available())
    Firmata.processInput();

// Handle network data and send it to 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 is little changed method of processInput where processInput reads data directly from FirmataSerial, and in this method we pass data down to method from network. This was tested and it should work fine.

Write method is overloaded in a different way. In Firmata.cpp I have added an method pointer that can be set to a custom method and used to send data using that custom method. I have then added custom method call after each of the 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 then set the overrided write method to a custom method that just writes byte to 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;
...
}

All stages pass right (I guess) and then I don't get any response from Node when I request pin states

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

There is no response. Any ideas why would that happen? Node receive all messages correctly and code for handling pin states exist.

$\endgroup$
  • $\begingroup$ There is a lot of information in your question, and it's a bit confusing since you were able to solve part of the problem. Could you edit your question and remove the parts of it that are related to what's been solved? That will make it easier to see where your issue might be. $\endgroup$ – Ian Feb 21 '13 at 19:32
  • 1
    $\begingroup$ Please take your solution and post it as an answer. Then we'll all happily upvote your answer as well. This also makes it appear the question was answered when people search for a similar issue. Thanks! $\endgroup$ – Josh Vander Hook Feb 21 '13 at 19:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.