Sending Raw Ethernet VSCP events with Arduino

The VSCP Level II Raw Ethernet Driver makes it possible to receive and send VSCP events packed in raw Ethernet frames. This means that there is no need for a TCP/IP stack and the program code occupied by this subsystem code can instead be used for other purposes.

Warning Frames are broadcasted over the Ethernet bus and if you start to send a lot of frames you will probably slow down you network. This method is intended for a maximum of a few hundred or so events per second. If you send more use TCP/IP instead.

For Arduino devices you can find a library here. There is some sample code here.

#include <SPI.h>         // needed for Ethernet library communication with the W5100 (Arduino ver>0018)
#include <Ethernet.h>
#include <utility/w5100.h>

SOCKET s; // our socket that will be opened in RAW mode
byte buf[512+14]; // buffer to send through socket
int buflen; // length of data to send

void setup()
  // initialize the w5100 chip and open a RAW socket
  W5100.writeSnMR(s, SnMR::MACRAW);
  W5100.execCmdSn(s, Sock_OPEN);

void loop()
  buflen = 38;

  // Dest Mac Address (Broadcast)
  buf[0] = 0xff;
  buf[1] = 0xff;
  buf[2] = 0xff;
  buf[3] = 0xff;
  buf[4] = 0xff;
  buf[5] = 0xff;

  // Src Mac Address
  buf[6] = 0x00;
  buf[7] = 0x0c;
  buf[8] = 0x29;
  buf[9] = 0x2f;
  buf[10] = 0xd4;
  buf[11] = 0x93;

  // VSCP frame type
  buf[12] = 0x25;
  buf[13] = 0x7E;

  // VSCP Raw Ethernet Frame Version
  buf[14] = 0x00;

  // VSCP Header
  buf[15] = 0x00;
  buf[16] = 0x00;
  buf[17] = 0x00;
  buf[18] = 0x00;

  // VSCP RAw Ethernet Sub. Address
  buf[19] = 0x00;
  buf[20] = 0x00;

  // VSCP Timestamp
  buf[21] = 0x00;
  buf[22] = 0x00;
  buf[23] = 0x00;
  buf[24] = 0x00;

  buf[25] = 0x00;
  buf[26] = 0x00;
  buf[27] = 0x00;
  buf[28] = 0x00;

  // VSCP Class
  buf[29] = 0x00;
  buf[30] = 0x14;

  // VSCP Type
  buf[31] = 0x00;
  buf[32] = 0x09;

  // VSCP Data size
  buf[33] = 0x00;
  buf[34] = 0x03;

  // VSCP Data
  buf[35] = 0x01;
  buf[36] = 0x02;
  buf[37] = 0x03;

  // sending buffer
  W5100.send_data_processing(s, buf, buflen);
  W5100.execCmdSn(s, Sock_SEND_MAC);

coding/sending_raw_ethernet_vscp_events_with_arduino.txt · Last modified: 2018/02/08 17:47 (external edit)
[unknown button type]
Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki