Problem writing large buffers

Help
Andy
2005-09-12
2013-03-22
  • Andy

    Andy - 2005-09-12

    Hello,
    i was happy to find this project, cause serial port communication under Windows is very complicated.

    I try to transmit a buffer of 30.000 bytes, but i can only receive 19.248 with a terminal programm.

    The port is configuered as follows:

                StreamSerPort = new SerialPort("Com1");
                StreamSerPort.BaudRate = 38400;
                StreamSerPort.Handshake = Handshake.RequestToSend;
                StreamSerPort.ReceivedEvent += new SerialReceivedEventHandler(OnRecv);

                string text = GetFileContent("1000.txt");
                byte[] buf = new byte[text.Length];
                buf = Encoding.ASCII.GetBytes(text);
                StreamSerPort.Write(buf,0,buf.Length);

     
    • Mr ChriZ

      Mr ChriZ - 2005-09-12

      There is a bug where by the baud rate doesn't change on the fly.  If all else fails try closing and reopening the port after setting the baud rate.
      I haven't used the handshaking stuff, so can't say what thats like.
      I'm curious as to how you know that your receiving
      .248 of a byte however.
      Since a byte can only at best be divided into 8 bits :-)
      I guess you could measure the high and low voltages... but thats over my head.

       
      • Andy

        Andy - 2005-09-12

        Thanks for your answer.

        The baud rate must be correct cause the characters of the string are correctly transmitted.

        The point '.' is not a decimal point, it stands for thousand.

         
    • Mr ChriZ

      Mr ChriZ - 2005-09-12

      Ah that makes more sense!
      I think it's the norm to use the comma symbol
      30,000

      Don't think I can offer that much more help really.
      I never send that much data through it, my data tends to be up to about 200 bytes long tops.
      I'm sending it in exactly the same way you are.

      Does the text file definitley contain ascii data?  If it's raw binary that will upset it.

      I presume you've assertained that buf definitly contains 30,000 bytes before sending.

      Sadly the author of this project seems to have disappeared off the face of the planet, so you might be on your own from here on.

      Sorry I can't be of more help!
      Chris.

       
    • Mr ChriZ

      Mr ChriZ - 2005-09-13

      Just out of curiosity
      Have you tried splitting the message in to two halfs and seeing if that works?

       
      • Andy

        Andy - 2005-09-13

        Ive not tried out this, i think it could work but its very tricky and doesnt eleminate the real cause.

        There must be a bug in the code. Ive tried out a serial class from CodeProject that works fine. But its not so universal cause it uses the abort function for multithreading and so it cant work with compact framework.

         
        • Mr ChriZ

          Mr ChriZ - 2005-09-13

          Intriguing.  I may have a go at it some time and
          see if i can work it out.

          It may help in the mean time if you could leave a link to the CodeProject class that you've found, for anyone else that runs into similar problems.

          I've tried several other classes, and alot of them have a bug on the receiving end, characters going missing etc.

          Cheers
          Chris.

           
    • Andy

      Andy - 2005-09-13

      Serial Communications: The .NET Way

      http://www.codeproject.com/dotnet/DotNetComPorts.asp

      Cheers
      Andy

       

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks