500SL watchdog
This commit is contained in:
parent
c34dc91ddf
commit
fc74aac1c9
7
Laser_Test/General.ino
Normal file
7
Laser_Test/General.ino
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
void Generate_Code()
|
||||||
|
{
|
||||||
|
//scroll chars
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -4,7 +4,6 @@
|
|||||||
HardwareSerial MySerial1(1);
|
HardwareSerial MySerial1(1);
|
||||||
HardwareSerial MySerial2(2);
|
HardwareSerial MySerial2(2);
|
||||||
|
|
||||||
|
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include <Adafruit_GFX.h>
|
#include <Adafruit_GFX.h>
|
||||||
#include <Adafruit_SSD1306.h>
|
#include <Adafruit_SSD1306.h>
|
||||||
@ -24,9 +23,15 @@ Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
|
|||||||
|
|
||||||
long now = 0;
|
long now = 0;
|
||||||
long prev = 0;
|
long prev = 0;
|
||||||
int incomingByte = 0; // for incoming serial data
|
int incomingByte = 0; // for incoming serial data
|
||||||
bool b_mode;
|
bool b_mode;
|
||||||
int lasertype = 0;
|
bool b_type;
|
||||||
|
int lasertype = 0; //Lasertype selected
|
||||||
|
//tbv 500SL
|
||||||
|
bool watchdog_send = false; //500SL Wachtdog send, thus switched to vectorservice protocol
|
||||||
|
|
||||||
|
//void Linx500SL_Watchdog();
|
||||||
|
//void Linx500SL_SendCode();
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
|
||||||
@ -37,7 +42,7 @@ void setup() {
|
|||||||
//init debug port
|
//init debug port
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
|
|
||||||
if(digitalRead(pin_LASERTYPE) != b_mode)
|
if(digitalRead(pin_LASERTYPE) == false)
|
||||||
{
|
{
|
||||||
Serial.println("Lasertype set to : Linx 500SL - baudrate 19k2");
|
Serial.println("Lasertype set to : Linx 500SL - baudrate 19k2");
|
||||||
//init serial ports
|
//init serial ports
|
||||||
@ -85,44 +90,39 @@ void loop() {
|
|||||||
|
|
||||||
if(digitalRead(pin_MODE) != b_mode)
|
if(digitalRead(pin_MODE) != b_mode)
|
||||||
{
|
{
|
||||||
b_mode = digitalRead(pin_MODE);
|
b_mode = digitalRead(pin_MODE);
|
||||||
if(b_mode)
|
if(b_mode)
|
||||||
{
|
{
|
||||||
Serial.println("Mode : Sniffer");
|
Serial.println("Mode : Sniffer");
|
||||||
|
display.clearDisplay();
|
||||||
display.clearDisplay();
|
display.setTextSize(1);
|
||||||
display.setTextSize(1);
|
display.setTextColor(SSD1306_WHITE);
|
||||||
display.setTextColor(SSD1306_WHITE);
|
display.setCursor(10,0);
|
||||||
display.setCursor(10,0);
|
if(lasertype==1) {display.println(F("Linx 500SL"));}
|
||||||
if(lasertype==1) {display.println(F("Linx 500SL"));}
|
if(lasertype==2) {display.println(F("MundiScan 2000"));}
|
||||||
if(lasertype==2) {display.println(F("MundiScan 2000"));}
|
display.setCursor(0,10);
|
||||||
display.setCursor(0,10);
|
display.println(F("Sniffer mode selected"));
|
||||||
display.println(F("Sniffer mode selected"));
|
display.display();
|
||||||
display.display();
|
delay(1000);
|
||||||
delay(1000);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
}
|
Serial.println("Mode : Generate code");
|
||||||
else
|
display.clearDisplay();
|
||||||
{
|
display.setTextSize(1);
|
||||||
Serial.println("Mode : Generate code");
|
display.setTextColor(SSD1306_WHITE);
|
||||||
display.clearDisplay();
|
display.setCursor(10,0);
|
||||||
display.setTextSize(1);
|
if(lasertype==1) {display.println(F("Linx 500SL"));}
|
||||||
display.setTextColor(SSD1306_WHITE);
|
if(lasertype==2) {display.println(F("MundiScan 2000"));}
|
||||||
display.setCursor(10,0);
|
display.setCursor(0,10);
|
||||||
if(lasertype==1) {display.println(F("Linx 500SL"));}
|
display.println(F("Send mode selected"));
|
||||||
if(lasertype==2) {display.println(F("MundiScan 2000"));}
|
display.display();
|
||||||
display.setCursor(0,10);
|
delay(1000);
|
||||||
display.println(F("Send mode selected"));
|
}
|
||||||
display.display();
|
|
||||||
delay(1000);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(b_mode)
|
if(b_mode)
|
||||||
{
|
{
|
||||||
if (MySerial1.available() > 0) {
|
if (MySerial1.available() > 0) {
|
||||||
@ -143,14 +143,52 @@ void loop() {
|
|||||||
Serial.println(incomingByte, DEC);
|
Serial.println(incomingByte, DEC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//generating mode
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
now = millis();
|
now = millis();
|
||||||
if(now - prev >= 5000)
|
if(now - prev >= 5000)
|
||||||
{
|
{
|
||||||
Serial.println(".");
|
|
||||||
MySerial1.println("P1 : Hallo Frank");
|
//Laser 500SL
|
||||||
MySerial2.println("P2 : Hallo Frank");
|
if(lasertype == 1)
|
||||||
|
{
|
||||||
|
if(!watchdog_send)
|
||||||
|
{
|
||||||
|
display.setCursor(0,20);
|
||||||
|
|
||||||
|
display.setTextColor(WHITE, BLACK);
|
||||||
|
|
||||||
|
display.println(F("Sending WATCHDOG "));
|
||||||
|
display.display();
|
||||||
|
|
||||||
|
Serial.println("Linx 500SL : Sending WatchDog command to switch to VectorService Protocol");
|
||||||
|
|
||||||
|
Linx500SL_Watchdog();
|
||||||
|
if(!watchdog_send) {Serial.println("Linx 500SL : Error !! --> No Response from laser");}
|
||||||
|
if(watchdog_send) {Serial.println("Linx 500SL : Laser switched to VectorService Protocol !!");}
|
||||||
|
|
||||||
|
display.setCursor(0,20);
|
||||||
|
display.setTextColor(WHITE, BLACK);
|
||||||
|
if(!watchdog_send) {display.println(F("No Response laser !! "));}
|
||||||
|
if(watchdog_send) {display.println(F("Laser Connected !! "));}
|
||||||
|
display.display();
|
||||||
|
delay(5000);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Linx500SL_SendCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(lasertype == 2)
|
||||||
|
{
|
||||||
|
Serial.println(".");
|
||||||
|
MySerial1.println("P1 : Hallo Frank");
|
||||||
|
MySerial2.println("P2 : Hallo Frank");
|
||||||
|
}
|
||||||
|
|
||||||
prev = now;
|
prev = now;
|
||||||
}
|
}
|
||||||
@ -158,5 +196,4 @@ void loop() {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
94
Laser_Test/Linx500SL.ino
Normal file
94
Laser_Test/Linx500SL.ino
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
|
||||||
|
byte SL500_SEQ = 00;
|
||||||
|
byte SL500_CRC = 00;
|
||||||
|
byte SL500_XOR = 00;
|
||||||
|
|
||||||
|
|
||||||
|
//char SL500SL_WD[] = {204,170,0,0,0,1,0,0,0,1,0,19,0,0,0,43,0,0,0};
|
||||||
|
char SL500_WD[] = {0xCC,0xAA,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x13,0x00,0x00,0x00,0x2B,0x00,0x00,0x00};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Send Wachtdog and wait for a reply to switch 500SL laser into VectorService Protocol
|
||||||
|
|
||||||
|
//Wachdog command CC AA 00 00 00 01 00 00 00 01 00 13 00 00 00 2B [SEQ] [CRC] [XOR]
|
||||||
|
|
||||||
|
void Linx500SL_Watchdog()
|
||||||
|
{
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
byte p2_rec_byte;
|
||||||
|
|
||||||
|
while ((!watchdog_send) && count < 15)
|
||||||
|
{
|
||||||
|
|
||||||
|
SL500_SEQ = SL500_SEQ + 1;
|
||||||
|
SL500_WD[16] = SL500_SEQ;
|
||||||
|
|
||||||
|
Linx500_Checksum(16);
|
||||||
|
|
||||||
|
SL500_WD[17] = SL500_CRC;
|
||||||
|
SL500_WD[18] = SL500_XOR;
|
||||||
|
|
||||||
|
|
||||||
|
Serial.println("Linx 500SL : WatchDog");
|
||||||
|
//Send karakters of the watchdog command
|
||||||
|
for (int i = 0; i <= 18; i++)
|
||||||
|
{
|
||||||
|
// MySerial1.print(SL500_WD[i], DEC);
|
||||||
|
MySerial1.write(SL500_WD[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Small delay to give the laser some time to respond
|
||||||
|
delay(500);
|
||||||
|
|
||||||
|
if (MySerial1.available() > 0)
|
||||||
|
{
|
||||||
|
// read the incoming byte:
|
||||||
|
p2_rec_byte = MySerial1.read();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(p2_rec_byte == 204)
|
||||||
|
{
|
||||||
|
watchdog_send = true;
|
||||||
|
}
|
||||||
|
count = count + 1;
|
||||||
|
delay(2000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//500SL Send Code
|
||||||
|
void Linx500SL_SendCode()
|
||||||
|
{
|
||||||
|
Generate_Code();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void Linx500_Checksum(int char_count)
|
||||||
|
{
|
||||||
|
|
||||||
|
long val_crc = 0;
|
||||||
|
long val_xor = 0;
|
||||||
|
|
||||||
|
//Checksum Calculation
|
||||||
|
for (int i = 0; i <= char_count; i++)
|
||||||
|
{
|
||||||
|
val_crc = val_crc + SL500_WD[i];
|
||||||
|
val_xor = val_xor ^ SL500_WD[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
val_crc = 255 - (val_crc % 256);
|
||||||
|
|
||||||
|
Serial.print("Checksum : ");
|
||||||
|
Serial.println(val_crc);
|
||||||
|
Serial.println(val_xor);
|
||||||
|
|
||||||
|
SL500_CRC = val_crc;
|
||||||
|
SL500_XOR = val_xor;
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user