Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. [VB.NET 2008] SerialPort and UART framing error

[VB.NET 2008] SerialPort and UART framing error

Scheduled Pinned Locked Moved .NET (Core and Framework)
hardwarecsharpcomhelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    steve_9496613
    wrote on last edited by
    #1

    Hi everybody, My application, written in vb.net VS2008, runs on a device with Windows Embedded Compact 7 operating system and for this reason uses COMPACT FRAMEWORK instead of full .NET. It communicates with another device by DMX512 protocol via RS485 port. When receiving data I need to catch the UART framing error and I'm not sure how to do. The SerialPort object has the ErrorReceived event and I try to catch this event. This is what I did in a short test app:

    ...
    com = New System.IO.Ports.SerialPort()
    ...
    AddHandler com.ErrorReceived, AddressOf ErrorReceived
    ...

    Private Sub ErrorReceived(ByVal sender As Object, ByVal e As SerialErrorReceivedEventArgs)

    MessageBox.Show(e.EventType.ToString)

    End Sub

    When I start receiving data using com.ReadByte() in a for loop, I receive all the bytes and then, very slowly, come up some MessageBox reporting the "RXOver" error (MSDN: An input buffer overflow has occurred...). I get no "Frame" error (MSDN: The hardware detected a framing error.) but in the DMX communication the break is too long not to rise a framing error. So: is this the right way to catch an error event for a SerialPort object? Am I missing something? Any suggestions would be greatly appreciated. Thanks in advance.

    M 1 Reply Last reply
    0
    • S steve_9496613

      Hi everybody, My application, written in vb.net VS2008, runs on a device with Windows Embedded Compact 7 operating system and for this reason uses COMPACT FRAMEWORK instead of full .NET. It communicates with another device by DMX512 protocol via RS485 port. When receiving data I need to catch the UART framing error and I'm not sure how to do. The SerialPort object has the ErrorReceived event and I try to catch this event. This is what I did in a short test app:

      ...
      com = New System.IO.Ports.SerialPort()
      ...
      AddHandler com.ErrorReceived, AddressOf ErrorReceived
      ...

      Private Sub ErrorReceived(ByVal sender As Object, ByVal e As SerialErrorReceivedEventArgs)

      MessageBox.Show(e.EventType.ToString)

      End Sub

      When I start receiving data using com.ReadByte() in a for loop, I receive all the bytes and then, very slowly, come up some MessageBox reporting the "RXOver" error (MSDN: An input buffer overflow has occurred...). I get no "Frame" error (MSDN: The hardware detected a framing error.) but in the DMX communication the break is too long not to rise a framing error. So: is this the right way to catch an error event for a SerialPort object? Am I missing something? Any suggestions would be greatly appreciated. Thanks in advance.

      M Offline
      M Offline
      Marco Bertschi
      wrote on last edited by
      #2

      Even though not being a Serial communication expert I'd say that there is an error with the hardware, for example a wrong Baud rate causing the buffer to overflow. Another idea to handle buffer overflows is to modify the hardware to delay the delivery of the messages sent over the Serial, or send less serial messages.

      steve_9496613 wrote:

      is this the right way to catch an error event for a SerialPort object?

      SerialPort throws an exception for occured errors, so I'd guess that it is the right way ( I did it the same way in an earlier project of mine, and it worked fine for me).

      steve_9496613 wrote:

      Am I missing something?

      The messages which get lost during the buffer overflow, I assume.

      You know the world is going crazy when the best rapper is a white guy, the best golfer is a black guy, the tallest guy in the NBA is Chinese, the Swiss hold the America's Cup, France is accusing the U.S. of arrogance, Germany doesn't want to go to war, and the three most powerful men in America are named "Bush", "Dick", and "Colon."

      S 1 Reply Last reply
      0
      • M Marco Bertschi

        Even though not being a Serial communication expert I'd say that there is an error with the hardware, for example a wrong Baud rate causing the buffer to overflow. Another idea to handle buffer overflows is to modify the hardware to delay the delivery of the messages sent over the Serial, or send less serial messages.

        steve_9496613 wrote:

        is this the right way to catch an error event for a SerialPort object?

        SerialPort throws an exception for occured errors, so I'd guess that it is the right way ( I did it the same way in an earlier project of mine, and it worked fine for me).

        steve_9496613 wrote:

        Am I missing something?

        The messages which get lost during the buffer overflow, I assume.

        You know the world is going crazy when the best rapper is a white guy, the best golfer is a black guy, the tallest guy in the NBA is Chinese, the Swiss hold the America's Cup, France is accusing the U.S. of arrogance, Germany doesn't want to go to war, and the three most powerful men in America are named "Bush", "Dick", and "Colon."

        S Offline
        S Offline
        steve_9496613
        wrote on last edited by
        #3

        Thanks Marco, the overflow error is not a big problem, I mean that it seems to be "automatically" managed: I didn't noticed it until I tried to catch errors and the reception was ok, i got all the bytes I expected. DMX is a serial communication at 250000 baud, I can't (and I don't need) to modify the baud rate. What I need to do is to catch the framing error that I'm sure occurs because the DMX data packet starts with a BREAK that lasts at least 88 µs and during which the line is low (zero).

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups