WriteBlock() public method

public WriteBlock ( int num, byte data ) : bool
num int
data byte
return bool
        protected void ParseSigBlockMessage(int status, byte[] msg)
        {
            System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();

            if (status == 2)
            {
                byte[] var_data = new byte[msg.Length - 14];
                for (int i = 0; i < var_data.Length; i++)
                {
                    var_data[i] = msg[i + 12];
                }
                sig_object.WriteBlock(msg[11] - 0x30, var_data);
                msg[11]++; // move to next sig block
            }

            if (sig_object.SigFull())
            {
                // signature capture complete
                string sigfile = "";
                try {
                    char sep = System.IO.Path.DirectorySeparatorChar;
                    sigfile = sig_object.BuildImage(MAGELLAN_OUTPUT_DIR + sep + "tmp");
                } catch (Exception e) {
                    if (this.verbose_mode > 0)
                    {
                        System.Console.WriteLine(e);
                    }
                }
                getting_signature = false;
                FileInfo fi = new FileInfo(sigfile);
                PushOutput("TERMBMP" + fi.Name);
                HandleMsg("termReset");
            }
            else
            {
                // get the next sig block or re-request the
                // current one
                string var_num = enc.GetString(new byte[6]
                {
                    msg[6], msg[7], msg[8], msg[9], msg[10], msg[11]
                });
                WriteMessageToDevice(GetVariableMessage(var_num));
            }
        }
示例#2
0
        private void ParseSigBlockMessage(int status, byte[] msg)
        {
            System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();

            if (status == 2)
            {
                byte[] var_data = new byte[msg.Length - 14];
                for (int i = 0; i < var_data.Length; i++)
                {
                    var_data[i] = msg[i + 12];
                }
                sig_object.WriteBlock(msg[11] - 0x30, var_data);
                msg[11]++;         // move to next sig block
            }

            if (sig_object.SigFull())
            {
                // signature capture complete
                string sigfile = "";
                try{
                    char sep = System.IO.Path.DirectorySeparatorChar;

                    sigfile = sig_object.BuildImage(INGENICO_OUTPUT_DIR + sep + "sig");
                }catch (Exception e) {
                    if (VERBOSE)
                    {
                        System.Console.WriteLine(e);
                    }
                }
                getting_signature = false;
                PushOutput(sigfile);
                ConfirmedWrite(GetLRC(HardResetMessage()));
            }
            else
            {
                // get the next sig block or re-request the
                // current one
                string var_num = enc.GetString(new byte[6]
                {
                    msg[6], msg[7], msg[8], msg[9], msg[10], msg[11]
                });
                ConfirmedWrite(GetLRC(GetVariableMessage(var_num)));
            }
        }