• 0

[C#] SerialPort Question


Question

2 answers to this question

Recommended Posts

  • 0

I believe it would be helpful if you told us which device you are using and what you are trying to accomplish, specifically. Maybe post a little code that you are having trouble with. Your description is quite vague.

While I have never tried interfacing with a serial port in C#, or Windows in general, I will try to help anyway. I worked on a project recently that involved interfacing with an Arduino board over its serial connection. For lack of further details on your part, I'm going to assume that your program will interface fairly similarly. I found this blog post by John Ciacia that describes interacting with the Arduino in C# in great detail. In fact, the demonstration code in his post looks very similar to my own implementation (in C++ for Linux, however).

For the record, I had the same problem as you with the data received being somewhat slow. Essentially, you need to know exactly how many characters you need to read from the serial device before starting the read operation, and block until you receive that specific number of characters. In my case, I found it easiest to send and receive only one character at a time. That worked for me because I didn't have exceptionally complex instructions to carry out. Since your device's output sequence seems to be 3 integers followed by a space, that approach may work for you too (but waiting for four characters instead of just one before returning).

If you wish, I will post my class so you can look at how I solved the problem. Note, however, that it is in a different language for a different operating system, although the concepts should be fairly similar.

PS: Make sure you are initializing the connection with the correct baud rate. You will not be able to get anything done if the baud rate is wrong!

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Putin was behind Farage/Brexit and behind Trump/MAGA. Different idiot lying beasts, same fascist master. Same screwed up results for both nations.
    • For me the Final Fantasy games, Langrisser I & II, Hardspace: Shipbreaker, Horizon Forbidden West Complete Edition, Metaphor: ReFantazio and LUNAR Remastered Collection
    • Limited Prime Day deal sees Amazon Echo Show 11 is at its lowest price yet by Ivan Jenic The Amazon Echo Show 11 is currently $149.99 on Amazon during Prime Day, down from $219.99. That's 32% off and $70 saved on Amazon's newest mid-size smart display (purchase link below). As its name suggests, the Echo Show 11 features a 11” Full-HD touchscreen, which is a decent upgrade over the Echo Show 8. It offers 60% more viewing area, which makes a genuine difference for recipes, calendars, video calls, or any other scenario where the smaller display can feel a bit cramped. The Show 11 is built around Alexa+, Amazon's more capable AI assistant that can handle natural conversation. You can make reservations, order groceries, and find content based on your preferences, instead of always having to give it precise commands. There’s also the Omnisense technology, which adds ambient awareness, allowing the device to trigger routines based on temperature, presence detection, or visual cues. Smart home control is built in without needing a separate hub, and the home screen doubles as a photo slideshow when not in use. Taking all of this into account, the Show 11 is a perfect smart addition to your kitchen counter or living room. At $149.99, this is a strong Prime Day buy for anyone already in the Amazon ecosystem or looking to build one out. Amazon Echo Show 11 - $149.99 | 32% off on Amazon Good to know This Amazon deal is U.S. specific, and not available in other regions unless specified. We only use first-party seller links (at the time of article publishing); ensure that you purchase from a first-party seller link only. Check out Today's Deals on Amazon | or our recent tech deals. Become a Prime member (for Students or SNAP) via Neowin Get Prime Access - Prime for half price (for qualifying Medicaid, EBT, SNAP) Subscribe to Prime Video, Audible Plus, Music Unlimited or Kindle Unlimited via Neowin As an Amazon Associate, we earn from qualifying purchases.
  • Recent Achievements

    • One Year In
      bernmeister earned a badge
      One Year In
    • Week One Done
      Scoobystu earned a badge
      Week One Done
    • Week One Done
      tuben earned a badge
      Week One Done
    • First Post
      OffsetAbs earned a badge
      First Post
    • Reacting Well
      OffsetAbs earned a badge
      Reacting Well
  • Popular Contributors

    1. 1
      +primortal
      465
    2. 2
      +Edouard
      217
    3. 3
      PsYcHoKiLLa
      157
    4. 4
      Steven P.
      74
    5. 5
      FloatingFatMan
      71
  • Tell a friend

    Love Neowin? Tell a friend!