ChamSys Ltd www.chamsys.co.uk
MagicQ User Manual 270 Version 1.4.9.0
31.3 Reading from the Ethernet
By default data received on the Ethernet is ignored. This can be changed to make MagicQ accept remote
commands received on the Ethernet port. In the View Settings view of the Setup Window, set the
Ethernet Remote Protocol to “ChamSys Rem rx”.
ChamSys Remote Protocol consists of simple commands consisting of a list parameter values separated by
commas ‘,’ and ending in a character A to Z (or a to z). Commands can contain spaces, tabs, and carriage
returns; they are all ignored. See the section on ChamSys Remote Protocol for further details.
31.4 Sample code fragments
The code fragments below show you could connect to MagicQ using simple C programming.
// ChamSys Ethernet remote protocol
#define REMOTE_ETHER_PORT 0x1999
#define MAX_CREP_MSG 1000
typedef struct {
long32 chamsys;
word16 version;
byte seq_fwd;
byte seq_bkwd;
word16 length;
byte data;
} remote_ether_message_t;
int remote_ether_sock = 0;
word16 remote_ether_fwd = 0;
word16 remote_ether_bkwd = 0;
int remote_ether_init(void)
{
struct sockaddr_in name;
char opts[100];
socklen_t optlen = 100;
int flags;
int i;
// For Windows OS we need to start winsocket
#ifndef LINUX
{
WSAData ws;
int code;
code = WSAStartup(MAKEWORD(1,1),&ws);
}
#endif
if (remote_ether_sock)
{
return (TRUE);
}
remote_ether_sock = socket (PF_INET, SOCK_DGRAM, 0);