From 8fbca26600486d4cc558e493d40499384573f5c0 Mon Sep 17 00:00:00 2001 From: gac-S_Changer Date: Thu, 31 Aug 2017 17:07:22 +0200 Subject: [PATCH] Startup --- plugins/LaserUE.java | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 plugins/LaserUE.java diff --git a/plugins/LaserUE.java b/plugins/LaserUE.java new file mode 100644 index 0000000..a87ee5c --- /dev/null +++ b/plugins/LaserUE.java @@ -0,0 +1,42 @@ + +import ch.psi.pshell.serial.SerialPortDevice; +import ch.psi.pshell.serial.SerialPortDeviceConfig; +import static ch.psi.utils.BitMask.*; + +/* + * + */ + +/** + * + */ +public class LaserUE extends SerialPortDevice{ + + public LaserUE(String name, String port) { + super(name, port, 921600, SerialPortDeviceConfig.DataBits.DB_8, SerialPortDeviceConfig.StopBits.SB_1, SerialPortDeviceConfig.Parity.None); + this.setMode(Mode.FullDuplex); + } + + int value = 0; + int count = 0; + @Override + protected void onByte(int rx) { + int index = ((rx&BIT7) > 0) ? 2 : (((rx&BIT6) > 0) ? 1 : 0); + if (count==index){ + if (index ==0){ + value = rx & 0x3F; + } else if (index ==1){ + value = ((rx& 0x3F)<<6) + value; + } else if (index ==2){ + value = ((rx& 0x0F)<<12) + value; + this.setCache(value); + count = 0; + } else { + count = 0; + } + } + else{ + count = 0; + } + } +}