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. C#
  4. SerialPort UART input buffer omits zeroes

SerialPort UART input buffer omits zeroes

Scheduled Pinned Locked Moved C#
helpcsharpquestion
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.
  • K Offline
    K Offline
    Karthik S Prakash
    wrote on last edited by
    #1

    Hi, I need to tranfer hex values through UART. But the problem is the default ASCII encoding of the SerialPort omits zeroes and such values (mostly below 0x14). What do I change this setting to in order to receive all values from 0-255 through the port? Please Help. For ex: 0x55, 0x55, 0x00, 0x00, 0x55, 0x55 comes through to the PC C# app as UUUU Regards, Karthik

    L 1 Reply Last reply
    0
    • K Karthik S Prakash

      Hi, I need to tranfer hex values through UART. But the problem is the default ASCII encoding of the SerialPort omits zeroes and such values (mostly below 0x14). What do I change this setting to in order to receive all values from 0-255 through the port? Please Help. For ex: 0x55, 0x55, 0x00, 0x00, 0x55, 0x55 comes through to the PC C# app as UUUU Regards, Karthik

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      If you want to send or receive all possible byte values, then your data isn't text, and you should stay away from all text-oriented methods and classes. So the words "ASCII" and "encoding" do not apply, just use the Read() and Write() methods which deal with byte arrays; they'll handle everything (unless you have set DiscardNull to true). :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


      I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


      K 1 Reply Last reply
      0
      • L Luc Pattyn

        If you want to send or receive all possible byte values, then your data isn't text, and you should stay away from all text-oriented methods and classes. So the words "ASCII" and "encoding" do not apply, just use the Read() and Write() methods which deal with byte arrays; they'll handle everything (unless you have set DiscardNull to true). :)

        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


        I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


        K Offline
        K Offline
        Karthik S Prakash
        wrote on last edited by
        #3

        @gszakacs : That did it! I set SerialPort.DiscardNull = False and I was able to see all the hex values. I was using code from a previous project where I used 50-50 encoding to transmit data. Thank you!

        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