Serial Soladin600

Hello, all

I like to implement a serial communication to a Soladin 600 http://wiki.firestorm.cx/index.php/Soladin
It start with sending over some byte's
0x0000: 16 bit destination address for the packet.
0x0000: 16 bit source address for the packet.
0x0000: 16 bit command ID.
So
TX: 00 00 00 00 C1 00 00 00 C1
RX: 00 00 11 00 C1 F3 00 00 C5

How can I do this without long code like this
void txprobe() {
Serial.write(SourceAdr[0] );
Serial.write(SourceAdr[1]);
Serial.write(DestAdr[0]);
Serial.write(DestAdr[1]);
Serial.write(Probe[0]);
Serial.write(Probe[1]);

Many Thanks,

http://arduino.cc/en/Reference/For

Yes, I was thinking about a loop to,
But how can I concatenate all these byte together, to send them in one loop

Teding,

I guess you could not store them in different arrays.

I came up with this so far,
I would like that function Concat returns buffer. Maybe with the use of a pointer ??

char* Concat(char des[2], char cmd[2]){

char SourceAdr[] = {  0x00, 0x00 };
char DestAdr[] = {  0x00, 0x00};
char Probe[] = {  0xC1, 0x00} ;  // Probe Command
char FirmID[] = { 0xB4, 0x00};  // Firmware information 
char DevStat[] = { 0xB6, 0x00} ;  // device status
char TxBuf[9] ;

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

void loop() {
  Concat(DestAdr,Probe);
  Serial.write(TxBuf);
  delay(2000); }

void Concat(char des[2], char cmd[2]){
  char buffer[] = { 0x00, 0x00, 0,0,0,0,0x00,0x00,0x00  }  ; // SourceAddress Always 0x000, 
  buffer[2] = des[0] ;  // Destination Address
  buffer[3] = des[1] ;
  buffer[4] = cmd[0];   // Comando
  buffer[5] = cmd[1];
  for (int i=0 ; i<8; i++){
    buffer[8] = buffer[8] + buffer[i] ;  //Checksum
  }
  for( int i=0; i<9; i++){
    TxBuf[i] = buffer[i];  }    //copy to Global buffer
//  TxBuf = buffer ;   Doesn't work => error: invalid array assignment
}

I would like that function Concat returns buffer. Maybe with the use of a pointer ??

No. Concat can not return buffer, or a pointer to buffer.
You can't return an array from a function.
buffer is a local variable that goes out of scope when the function ends, so you can't return a pointer to it.

What you can do is pass (by reference) the array that you want the data copied into.

void Concat(char des[2], char cmd[2], char *OutBuf)
{
  char buffer[] = { 0x00, 0x00, 0,0,0,0,0x00,0x00,0x00  }  ; // SourceAddress Always 0x000, 
  buffer[2] = des[0] ;  // Destination Address
  buffer[3] = des[1] ;
  buffer[4] = cmd[0];   // Comando
  buffer[5] = cmd[1];
  for (int i=0 ; i<8; i++)
  {
    buffer[8] = buffer[8] + buffer[i] ;  //Checksum
  }
  for( int i=0; i<9; i++)
  {
    OutBuf[i] = buffer[i];
  }
}

Then call it:

  Concat(DestAdr,Probe,TxBuf);

The link in the opening post is not working anymore. Does anyone have a stored copy?

I would like to communicate with my Soladins as well. How did you handle the hardware side?

Thanks, Peter

Peter,
I did notice, that the site went offline.
Too bad. I do have a hard copy, that i can pdf. If you sent me your email by PM,
I will post them to you.
About the hardware, that is very simple. I use two resistor and a cut in half telephone connection cable.
I will draw you a diagram aswell.

This is the info soladin reported back on devicestate call.
PV= 86.40V 0.15A
AC= 10W 99.57KW
AC= 50.02Hz 232Volt
DevT= 22C AlarmFlag= 0
Total Operating time= 81105

This is the hardware part,
see Attachment

Thanks Teding!

The hardware connection should be doable for me :smiley:

I am relatively new to this, but if I read the diagram correctly I only need two digital pins to communicate with one unit: one for RX and one for TX?

Peter