Bachelorthesis/Modbus/socket.can

130 lines
1.5 KiB
Text
Raw Normal View History

2014-05-08 15:34:28 +02:00
/*@!Encoding:1252*/
includes
{
2014-05-08 16:08:33 +02:00
#include "ModbusCommon.cin"
#include "ModbusUdpCommon.cin"
2014-05-08 15:34:28 +02:00
}
variables
{
msTimer muster;
byte gX[2] = {1, 0};
}
// Get information of local network interface such like ip address
on preStart
{
writeClear(0);
setStartdelay(1000);
}
on start
{
long fehler;
ModbusInit("192.168.1.3", 502);
}
2014-05-08 16:07:38 +02:00
on key 'r'
{
ModbusReadBits(0, 512);
}
2014-05-08 15:34:28 +02:00
on key 'a'
{
byte x[16] = {1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0};
ModbusWriteBitsB(0, 16, x);
}
on key 's'
{
byte x[16] = {0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1};
ModbusWriteBitsB(0, 16, x);
}
on key 'Y'
{
ModbusWriteBit(0, 0);
}
on key 'y'
{
ModbusWriteBit(0, 1);
}
on key 'X'
{
ModbusWriteBit(1, 0);
}
on key 'x'
{
ModbusWriteBit(1, 1);
}
on key 'C'
{
ModbusWriteBit(2, 0);
}
on key 'c'
{
ModbusWriteBit(2, 1);
}
on key 'V'
{
ModbusWriteBit(3, 0);
}
on key 'v'
{
ModbusWriteBit(3, 1);
}
on key '+'
{
byte x[2] = {0xFF, 0xFF};
ModbusWriteBits(0, 16, x);
}
on key '-'
{
byte x[2] = {0x00, 0x00};
ModbusWriteBits(0, 16, x);
}
on key 't'
{
2014-05-08 17:22:21 +02:00
setTimerCyclic(muster, 100);
2014-05-08 15:34:28 +02:00
}
on key 'T'
{
cancelTimer(muster);
}
on timer muster
{
2014-05-08 17:22:21 +02:00
/*if (gX[0] != 0)
2014-05-08 15:34:28 +02:00
{
if (gX[0] == 0x80)
{
gX[0] = 0x00;
gX[1] = 0x01;
}
else
gX[0] <<= 1;
}
else
{
if (gX[1] == 0x80)
{
gX[0] = 0x01;
gX[1] = 0x00;
}
else
gX[1] <<= 1;
}
2014-05-08 17:22:21 +02:00
ModbusWriteBits(0, 16, gX);*/
ModbusReadBits(0, 512);
2014-05-08 15:34:28 +02:00
}
/**/