String Messages to Arduino with Firmata/Sysex

I am attempting to send messages to the Arduino with C#/Firmata. Although there are no problems sending ordinary pin commands (HIGH/LOW/PWM), I can't seem to figure out how to send a string of data to the Arduino for use within a subsequent procedure. I assume the best way to do this is through the use of SYSEX messages and attaching a Callback procedure to execute when the Arduino receives the SYSEX message, but please advise if anyone has a better suggestion.

Ideally, I would like to pass three paramaters to the Sysex Callback procedure -

  1. the pin number the IR Emitter is located on,
  2. a string that represents the Infrared Emitter Pulse Data,
  3. the IR frequency.
C# code:
        public void sendIRWrite(int pin_number, string IRPulseStream, int Mhz)
        {      
               byte[] message = new byte[5];
               message[0] = Arduino.START_SYSEX;
               message[1] = pin_number;
               message[2] = IRPulseStream;
               message[3] = Mhz;
               message[3] = Arduino.END_SYSEX;
               _serialPort.Write( message, 0, 3);
        }

I believe the message needs to be sent as 'bytes', but how does that translate in sending the string of IRPulseStream?

Firmata Attachment
    Firmata.attach(ANALOG_MESSAGE, analogWriteCallback);
    Firmata.attach(DIGITAL_MESSAGE, digitalWriteCallback);
    Firmata.attach(REPORT_ANALOG, reportAnalogCallback);
    Firmata.attach(REPORT_DIGITAL, reportDigitalCallback);
    Firmata.attach(SET_PIN_MODE, setPinModeCallback);
    Firmata.attach(START_SYSEX, processIRCallback);
Callback Procedure
void  processIRCallback(int pin, string IRPulseStream, int Mhz)
{
      // TBD - procedure to send IR pulse stream to IR emitter.
}

I have scoured Arduino.cc and Google for solutions but have not been able to find a good example to model. Is this type of functionality possible? Would someone be kind-enough to steer me in the right direction?

Thanks,
Bill

Anyone have any suggestions?

I am attempting to send messages to the Arduino with C#/Firmata. Anyone have any suggestions?

Yes. Dump Firmata, and write your own protocol. You'll understand it far better than Firmata, and it will do everything YOU want it to do. It really isn't that hard. Start by making a list of all the things the Arduino should do. Read a digital pin (<R,5>), set a digital pin (<W,6,H>), read an analog pin (<A,3>), etc. Keep the commands short. Order the data reasonably.

What kind of string are you needing to send to the Arduino for it to "use within a subsequent procedure."? How are you planning to tell the Arduino to execute that procedure?

Good-Morning Paul,

Once again, thanks for your assistance. If I get anywhere with the Arduino, it's because of your help.

A typical IRPulseStream would be "":00 :00 :00 :00 :00 :00 :00 :01 :00 :01 :01 :02". I am hoping to use Ken Shirriff's Infrared Remote Library to send the IR stream.

I am going to move off of Firmata and take a whack at putting together my own protocol as you suggested. In the end, I'll probably walk away with a whole lot more knowledge if I had to 'bang-it-out' myself.

Regards,
Bill