• 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

    • Epic Games says Unreal Engine 6 will help developers "build content faster" using AI models by Pulasthi Ariyasinghe Epic Games is rolling out the latest major update to Unreal Engine 5 today, and at the same time, the company also dropped some information on the next-generation version of the product, Unreal Engine 6. This was already revealed a few weeks ago alongside the new Rocket League upgrade reveal. The company says it is combining the features of Unreal Engine and Unreal Editor for Fortnite to create this new version of its popular media creation tool. On top of creating entire games, the new engine will also focus on letting developers operate large-scale live service titles more easily, whether by shipping content into their own ecosystems or into Fortnite. The use of large language models is also mentioned here, with Epic saying it will be a core part of the engine. "We see LLMs, generative AI models, and tools like Claude and Codex playing a central role in helping you build content faster while maintaining the creative control you need," adds the company. Here is the rundown of what's new about version 6 of Unreal Engine: With all these changes to the programming model, portability upgrades, and generative AI integration, Epic says the new version of the engine will "change a lot about how games are made." The company aims to ship Unreal Engine 6 into early access in late 2027, with a full release planned for 12-18 months later. Epic Games also dropped a lengthy blog post about the new Unreal Engine 5.8 update for game developers over here. The release is focused on delivering better performance, customization, and streamlined workflows for development teams. This will be the final major update for this version of the engine before Epic switches to focus fully on Unreal Engine 6's early access launch.
    • Watch Louis Rossmann's recent experience on YouTube about trying to get a warranty replacement from Samsung. It's crazy.
    • That is the thing, how many of these people don't realise they are using AI? If they use Google Search they have no choice but to use AI. So yes, maybe half of American adults do use and I expect a lot of Uk adults do to, but I bet most of them don't realise it. Myself, i avoid the rubbish.
    • They use FREE AI. They aren't paying for this meme-generating slopware...
    • Gotta' buy that there Rufus guy a beer if I ever meet him. He makes good stuff.
  • Recent Achievements

    • One Month Later
      Vincian earned a badge
      One Month Later
    • First Post
      Jocimo earned a badge
      First Post
    • Week One Done
      suprememobiles48 earned a badge
      Week One Done
    • One Month Later
      Windows Guy earned a badge
      One Month Later
    • One Month Later
      Prasann earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      499
    2. 2
      +Edouard
      165
    3. 3
      PsYcHoKiLLa
      89
    4. 4
      Steven P.
      69
    5. 5
      neufuse
      65
  • Tell a friend

    Love Neowin? Tell a friend!