1
    public void writeToCard2(string sourceText, string cardType)
    {
        Cursor.Current = Cursors.WaitCursor;

        int itemLength = sourceText.Split(',').Length;
        sourceText = itemLength.ToString() + "," + sourceText + ",";
        byte[] dataByteArray = Encoding.GetEncoding(932).GetBytes(sourceText);
        //textBox2.Text = BitConverter.ToString(dataByteArray);

        int dataByteLength = dataByteArray.Length;
        int writeLength = dataByteLength + 11;
        byte[] writeByteArray = new byte[writeLength];

        writeByteArray[0] = 0x02;//STX
        writeByteArray[1] = 0x00;//アドレス
        writeByteArray[2] = 0x78;//コマンド
        writeByteArray[3] = Convert.ToByte(dataByteLength + 4);//データ長
        writeByteArray[4] = 0xa1;//詳細コマンド
        writeByteArray[5] = 0x00;//書き込み開始ブロック番号
        writeByteArray[6] = Convert.ToByte(dataByteLength);//書き込みバイト数
        for (int i = 0; i < dataByteLength; i++)
        {
            writeByteArray[i + 7] = dataByteArray[i];//書き込みデータ
        }
        writeByteArray[dataByteLength + 7] = 0x40;//オプションフラグ
        writeByteArray[dataByteLength + 8] = 0x03;//ETX
        byte sum = 0x00;
        for (int i = 0; i <= dataByteLength + 8; i++)
        {
            sum += writeByteArray[i];
        }
        writeByteArray[dataByteLength + 9] = sum;//SUM値
        writeByteArray[dataByteLength + 10] = 0x0d;//CR

        //string tempStr = BitConverter.ToString(writeByteArray);

        //port.Write(writeByteArray, 0, writeByteArray.Length);
        serialPort1.Write(writeByteArray, 0, writeByteArray.Length);

        writeCardType = cardType;

        Cursor.Current = Cursors.Default;
    }

the above method writes data on an rfid tag in the line

serialPort1.Write(writeByteArray, 0, writeByteArray.Length);

writeByteArray is the size of the data which is exceeding the limit of the RFID tag, my boss said convert it to ascii code and then write to RFID.

Will this help can this conversion reduce size of data?

Is there any other way round withoud using a different RFID tag?

4

1 回答 1

1

您的老板说要转换为ASCII导致设备每字节读取信息。我使用这些设备,这是他们读取传递给他们的数据流的常用方式。

这并没有任何分配好处,因为数据的大小保持不变,变化的是信息表示。那是。

于 2012-07-12T08:54:11.717 回答