private void InforHandle() { while (true) { try { lisSock.Receive(recvBuf, BUF_SIZE, SocketFlags.None); } catch (Exception) { return; } ProAnalyser proAnalyser = new ProAnalyser(); ushort check = ProAnalyser.crc_check(recvBuf, recvBuf[3] + 4); if (((check & (ushort)(0xFF00)) >> 8) != recvBuf[recvBuf[3] + 4] || (check & (ushort)(0x00FF)) != recvBuf[recvBuf[3] + 4 + 1]) { //Incorrect CRC , discard ... continue; } proAnalyser.Decode(recvBuf); lock (mtx) { io = proAnalyser.io; isUpdate = true; } } }
private int Verify() { ProAnalyser proAnalyserSend = new ProAnalyser(); proAnalyserSend.OpVerifyInit(); try { lisSock.Send(proAnalyserSend.Encode()); } catch (Exception) { return(-1); } return(0); }
public int ResetBit(int wcStm, int wcBit) { ProAnalyser proAnalyserSend = new ProAnalyser(); byte[] io = new byte[10]; io[wcBit / 8] = (byte)(0x80 >> (wcBit % 8)); proAnalyserSend.OpResetInit(io, wcStm); try { lisSock.Send(proAnalyserSend.Encode()); } catch (Exception) { return(-1); } return(0); }
public byte[] GetBits(int wcStm) { ProAnalyser proAnalyserSend = new ProAnalyser(); proAnalyserSend.OpQueryInit(wcStm); try { lisSock.Send(proAnalyserSend.Encode()); } catch (Exception) { return(null); } if (isUpdate == true) { lock (mtx) { isUpdate = false; return(this.io); } } return(null); }