Arduino Ethernet with Insteon SmartLinc [Solved]

I'm working on a sketch that lets me send commands to the Insteon SmartLinc PLM. The SmartLinc has a hidden port at 9761 that allows you to send Insteon and X10 commands directly to it and receive any commands sent to it from other devices. I've successfully done it in python but the Arduino Ethernet Library seems to have been designed mainly with HTTP in mind, and the SmartLinc isn't able to deal with the extra 2 bytes that the Ethernet Library appends to my command. My code is as follows:

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {0x90,0xA2,0xDA,0x00,0x5E,0xCF};
IPAddress server(192,168,0,108);
char command_on[] = {0x02,0x62,0x14,0xA1,0x15,0x0F,0x11,0xFF}; // Insteon command for light device on
char command_off[] = {0x02,0x62,0x14,0xA1,0x15,0x0F,0x13,0xFF}; // Insteon command for light device off

EthernetClient client;

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

  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    for(;;)
      ;
  }
 
  delay(1000);
  Serial.println("Connecting...");

  // connect to SmartLinc
  if (client.connect(server, 9761)) {
    Serial.println("Connected");
    client.write(command_on); // Send just the command
  } 
  else {
    Serial.println("Connection Failed");
  }
}

void loop()
{
  if (client.available()) {
    byte c = client.read();
    if (c < 16) // Just formats hex better for serial output (it drops the leading 0 in a hex byte if its < 16 and thats ugly)
      Serial.print('0');
    Serial.print(c,HEX); // print what is received in hex
    Serial.print(' ');
  }
}

Now this ALMOST works but here is my serial communication when sending:

Connecting...
Connected
02 62 14 A1 15 0F 11 FF 01 04 15

Now the hex it returned should be a duplicate of the command I sent, with 06 on the end(meaning the Insteon device received it successfully). The Arduino is sending the 2 extra 01 and 04 bytes which malform the command and an error is appended in the reply of 15.

So my question is: is there any way to disable these 2 bytes from being sent at the end of the write? (04 in ascii means End of Transmission so I'm assuming the arduino is doing this on purpose).

The Arduino is sending the 2 extra 01 and 04 bytes which malform the command and an error is appended in the reply of 15.

No, the Arduino isn't doing it. You are.

char command_on[] = {0x02,0x62,0x14,0xA1,0x15,0x0F,0x11,0xFF}; // Insteon command for light device on

This is not a NULL terminated array of characters.

    client.write(command_on); // Send just the command

Yet, you are sending the data as though the array is NULL terminated.

You can either NULL terminate the array OR tell the client.write() function how many characters are in the non-NULL terminated array.

Thanks! Everything works now :smiley:

I realize this is an OLD post, however I have been scouring the net to find a way to communicate with Insteon via arduino or the arduino IDE. Since I am new to arduino and any form of programming, I have been absorbing as much new info and knowledge and googling everything I do not understand, along the way.

I'd be very grateful if you could share with me the final code, after your last post.

Sincerely,
Michael

I too am looking into using Insteon with Arduino and would like to see the working code if possible. I have Insteon product on order + I have received an insteon shield from GoodRobot.
BobbyD