void parse_hdlc(parseCallback process, byte *buffer, ref int bufidx, int bufsz, byte *input, int inlen) { for (int i = 0; i < inlen; i++) { byte b = input[i]; if (b == 0x7E) { if (bufidx >= 0) { process(buffer, bufidx); } bufidx = 0; } else if (bufidx >= 0) { if (bufidx == bufsz) { throw new Exception("HDLC buffer overflow"); bufidx = -1; continue; } buffer[bufidx++] = b; } } }
private StreamWriter writer; //write to network #endregion Fields #region Constructors public MainForm() { //starts app parser = new parseCallback(parseQuacket); this.FormClosing += onFormClosing; InitializeComponent(); System.Diagnostics.Debug.WriteLine("Started app."); }