Example #1
0
        //To read the short messages in the TFT screen devices (Filename:sms.dat)
        private void btnSSRSMSRead_Click(object sender, EventArgs e)
        {
            UDisk udisk = new UDisk();

            byte[] byDataBuf = null;
            int    iLength;
            int    iCount;//count of short messages

            int    iTag          = 0;
            int    iID           = 0;
            int    iValidMinutes = 0;
            int    iReserved     = 0;
            string sStartTime    = "";
            string sContent      = "";

            lvSSRSMS.Items.Clear();
            openFileDialog1.Filter   = "sms(*.dat)|*.dat";
            openFileDialog1.FileName = "sms.dat";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                FileStream stream = new FileStream(openFileDialog1.FileName, FileMode.OpenOrCreate, FileAccess.Read);
                byDataBuf = File.ReadAllBytes(openFileDialog1.FileName);

                iLength = Convert.ToInt32(stream.Length);
                if (iLength % 332 != 0)
                {
                    MessageBox.Show("Data Error!", "Error", MessageBoxButtons.OK);
                    return;
                }
                iCount = iLength / 332;

                for (int j = 0; j < iCount; j++)//loop
                {
                    byte[] bySMSInfo = new byte[332];
                    for (int i = 0; i < 332; i++)
                    {
                        bySMSInfo[i] = byDataBuf[j * 332 + i];
                    }
                    udisk.GetSSRSMSFromDat(bySMSInfo, out iTag, out iID, out iValidMinutes, out iReserved, out sStartTime, out sContent);

                    ListViewItem list = new ListViewItem();
                    list.Text = iTag.ToString();
                    list.SubItems.Add(iID.ToString());
                    list.SubItems.Add(iValidMinutes.ToString());
                    list.SubItems.Add(iReserved.ToString());
                    list.SubItems.Add(sStartTime);
                    list.SubItems.Add(sContent);
                    lvSSRSMS.Items.Add(list);

                    bySMSInfo = null;
                }
                stream.Close();
            }
        }
Example #2
0
        //To read the short messages in the TFT screen devices (Filename:sms.dat)
        private void btnSSRSMSRead_Click(object sender, EventArgs e)
        {
            UDisk udisk = new UDisk();

            byte[] byDataBuf = null;
            int iLength;
            int iCount;//count of short messages

            int iTag = 0;
            int iID = 0;
            int iValidMinutes = 0;
            int iReserved = 0;
            string sStartTime = "";
            string sContent = "";

            lvSSRSMS.Items.Clear();
            openFileDialog1.Filter = "sms(*.dat)|*.dat";
            openFileDialog1.FileName = "sms.dat";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                FileStream stream = new FileStream(openFileDialog1.FileName, FileMode.OpenOrCreate, FileAccess.Read);
                byDataBuf = File.ReadAllBytes(openFileDialog1.FileName);

                iLength = Convert.ToInt32(stream.Length);
                if (iLength % 332 != 0)
                {
                    MessageBox.Show("Data Error!", "Error", MessageBoxButtons.OK);
                    return;
                }
                iCount = iLength / 332;

                for (int j = 0; j < iCount; j++)//loop
                {
                    byte[] bySMSInfo = new byte[332];
                    for (int i = 0; i < 332; i++)
                    {
                        bySMSInfo[i] = byDataBuf[j * 332 + i];
                    }
                    udisk.GetSSRSMSFromDat(bySMSInfo, out iTag, out iID, out iValidMinutes, out iReserved, out sStartTime, out sContent);

                    ListViewItem list = new ListViewItem();
                    list.Text = iTag.ToString();
                    list.SubItems.Add(iID.ToString());
                    list.SubItems.Add(iValidMinutes.ToString());
                    list.SubItems.Add(iReserved.ToString());
                    list.SubItems.Add(sStartTime);
                    list.SubItems.Add(sContent);
                    lvSSRSMS.Items.Add(list);

                    bySMSInfo = null;
                }
                stream.Close();
            }
        }