上次发文,还是没搞定,我已经搞了1半,实在搞不下去了           SerialPort sp = new SerialPort();//和串口通讯,发到LED显示屏            byte[] b1 = new byte[31];
            byte[] b2 = new byte[31];
                int a0 = b1[0] - 160;
                int a1 = b1[1] - 160;
                int b = (94 * (a0 - 1) + (a1 - 1)) * 32;
                FileStream fs = new FileStream(@"Hzk16", FileMode.Open, FileAccess.Read);
                BinaryReader br = new BinaryReader(fs);
                b1 = br.ReadBytes(b);
            sp.Open(); //打开串口
            sp.Write(b1, 0, 31); //发送
            sp.Close();说明下,如果b1是正确的数组,就可以在LED上显示正确的汉字了比如,
byte[] b1 = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfF,。。}32个0xff就可以看到,LED的灯是全亮的,如果是0x00就不亮,问题是我中间那段好像有问题b1 = br.ReadBytes(b);无法编译,望高人解决啊

解决方案 »

  1.   

    说明下,LED是16X16的,每个汉字都是16X16的点阵显示
      

  2.   

    你直接读就行了,为什么还要用BinaryReader转一下,除非你是用binaryWrite写的。例如:
    FileStream fs = new FileStream(@"Hzk16", FileMode.Open, FileAccess.Read);
    //Read byte using fs.ReadByte
    //Read bytes using fs.Read
      

  3.   

    直接读后要如何赋值给b1呢?            sp.Write(b1, 0, 31); //发送串口的第一个参数必须是byte[]啊,就是那个b1,才可以显示汉字
      

  4.   

    FileStream fs = new FileStream(@"Hzk16", FileMode.Open, FileAccess.Read);
    BinaryReader br = new BinaryReader(fs);
    byte[] me=new byte[bt.Length];
    br.Read(me,0,me.Length);
    fs.Close();
      

  5.   

    to
    直接读后要如何赋值给b1呢?
    sp.Write(b1, 0, 31); //发送
    串口的第一个参数必须是byte[]啊,就是那个b1,才可以显示汉字Sample code as follows:
    FileStream fs = new FileStream(@"Hzk16", FileMode.Open, FileAccess.Read);
    //Read bytes using fs.Read
    byte[] b1 = new byte[31];
    fs.Read( b1, 0, 31 );
    sp.Write( b1, 0, 31 );//Send