Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How to use a serial com port with SFML  (Read 4238 times)

0 Members and 1 Guest are viewing this topic.

Ivo

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
How to use a serial com port with SFML
« on: September 19, 2013, 02:07:08 am »
Hello,

I'm new to SFML, working through the tutorials, all good so far, but what I need and cannot find is how to use a serial port with SFML.

OS is Windows 7, IDE is Visual Studio 2012 Express, SFML version 2.1.

Background: I have to develop a basic computer game which uses the input of two microcontrollers connected with serial ports.

Question: I would like to have events similar to the mouse or keybord events whenever data are received on the serial port (and of course send something sometimes). Is there anything like that in SFML available?

Thank you, Ivo



eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10829
    • View Profile
    • development blog
    • Email
Re: How to use a serial com port with SFML
« Reply #1 on: September 19, 2013, 02:14:52 am »
SFML doesn't have any kind of API for working with serial ports. It's a multimedia library not a generic library that can handle anything.
What do you want to do with the serial port? :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Ivo

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: How to use a serial com port with SFML
« Reply #2 on: September 19, 2013, 02:34:49 am »
The game I have to develop has a microcontroller as input device. It sends out measurement data, every 10ms 30 ASCII bytes using Bluetooth.
I have to read these data, move simple geometric objects on the screen and in addition dump the data in a logfile. I have set up a virtual com port using a Bluetooth manager provided with my laptop. My first approach was a Visual Basic solution. It does the job but it's not fast enough, it can only process 10 events per second, not 100 as requested.
In VB I have a com port and whenever the application gets a 'receive' event I just read the data and process them.


eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10829
    • View Profile
    • development blog
    • Email
Re: How to use a serial com port with SFML
« Reply #3 on: September 19, 2013, 02:45:38 am »
You'll have to go and use the WinAPI directly. Google yields a lot of useful information on Serial ports and C++ (e.g. here, here, here or here). With C++ you can of course also consider using Bluetooth directly (e.g. see here).
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

fallahn

  • Sr. Member
  • ****
  • Posts: 492
  • Buns.
    • View Profile
    • Trederia
Re: How to use a serial com port with SFML
« Reply #4 on: September 19, 2013, 08:17:06 am »
A while back I wrote a class specifically for talking to microcontrollers over RS232 which wraps both windows and Linux APIs in a single cross platform interface, here which might help
« Last Edit: September 19, 2013, 10:36:18 am by fallahn »

Ivo

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: How to use a serial com port with SFML
« Reply #5 on: September 20, 2013, 01:17:35 am »
Thanks for the reply and the help, guys.
Now I'm working my way through the information you provided.

 

anything