USB Input/output or other approaches

Hello, I have Haiku on my laptops (System 76, Dell and HP). All have a common fault, they have no serial or parallel ports that I can program to drive my own hardware designs.

Years ago there was a USB-PIO design shown, is it still available for Haiku? Or something like it? If so how would I access it in my programs?

Alternatively, I could try modifing a USB keyboard as an input but I don’t know the scan rate for keyboards so I don’t know how fast I can input data yet.

Also there are USB joysticks, do those work with Haiku yet? If yes I can buy one tomorrow, again do you know how fast the joystick is scanned in?

Lastly, looking at the USB updates there is something called a USB Sensor Hub, but so far the ones I found on the internet have a slow scan rate.

For my purposes I need to do 1000 samples per second, I don’t think the keyboard mod will work that fast, can anyone help point me in the right direction.

I thought that USB-Serial worked fine in Haiku – it’s only no good for KDL output.

I have a USB GameController (a.k.a Joystick) that works well, and I use a lot in Haiku, and another that doesn’t in the revision I’m using. It did once, and Adrien says he has fixed it in the current rev, but I haven’t yet been able to update to test it. The one that works is a Thrustmaster “Top Gun”, the one that doesn’t (ATM) is a Microsoft “Sidewinder Strategic Commander”.

No idea about scanning. I sort of assumed that (unlike an analog stick) the controller transmits events at its own rate. Plenty fast for anything I want to do (usually sending MIDI events to fluidsynth or csound).

There is no serial ports on my laptops, just USB, Ethernet, and Video (HDMI and/or VGA).

Yes, I know… You were talking about USB-Serial, and so am I. I assumed you were thinking of the USB<>Serial converters that are available. As far as I know they work fine in Haiku

No, I was talking Serial Serial - no USB. And by the way I got a USB to Serial adapter, I have not figured out how to use it under Haiku either.

If you have some pointers I would be grateful.

Thank you about the joy-stick, I will see if it is available at my local stores.

I am using serial and USB serial as well with Haiku, using Lazarus (so in Pascal). Works very nice,although in FPC two files have to be updated (posix). My programs use SynaSer (a bit adapted) and these updated posix files, to adress my own (well our companies) hardware.

If you need USB to serial converter chips, I’d advice to use FTDI chips for that. Very nice, multi platform useable, and used in our companies for years (also today on Haiku connecting to my data aquisition hardware that has a hardware serial port, connected to Haiku via FTDI USB<>serial.

I did not test using serial ports (USB serial) directly in C/C++ within Haiku yet though.

Oh BTW: there is a library from FTDI to use digital I/O directly on those chips, in the form of a DLL. I never used that though. I don’t know if such a library exists for Linux or Haiku. In my case I just use a microcontroller with own firmware that reads/writes I/O ports, adressed using the RS232 connection.

If you’re interested, I’ve put together a zip file with SynaSer and termios updates for current Haiku and Lazarus/FPC:

USB to serial adapters would be the simplest thing indeed. Haiku supports FTDI, Prolific, and Silicon Labs chips, as well as anything implementing the standard USB ttyACM interface. Usage is through BSerialPort and you can do some tests with SerialConnect. The ports are in /dev/ports just like “real” serial ports.

Gamepads and USB joysticks work, through the BJoystick API. The device is indeed responsible for the rate at which you can get events, usually every 12.5ms or so.

For anything more specific (I/O ports and the like) you will probably want to use the USB Kit directly or use libusb. The latter is standard also on other OS for the same usage so anything that uses it should work fine (but there are known bugs). Using FT2232 chips or some of Cypress devices, this makes it easy to implement custom protocols.

Finally, the Arduino SDK is available, which is also an option and probably a good compromise between ease of use and flexibility.

I would just like to mention that while original Arduinos work well under Haiku (tested by myself), the cheap clones don’t, because they use CH340 chip for USB connectivity, and our libs don’t support it yet.

Ah, right, forgot about WCH chips. Support shouldn’t be too hard to add. Can you make a bugreport about that?


First, thank you to all the people who have tried to help me.

I got the USB to Serial cable to work, it did not work when I tried it last year, but that could easier be my fault because of the wiring I used.

My first experiment suggest it is going at full baud rate of 3,000,000 bits per second (I could be wrong) but I know plan to build hardware to convert the serial stream to a parallel output.

To my surprise I could not find a simple TTL UART circuit that using Google. I remember they existed in my old PET days (yes, I am that old) but all I could find is software UARTs and some hardware designs that need the chips to be on a CPU bus.

I need a simple serial->parallel design that I can just stream bytes to for my needs. So I am designing one of my own. Assuming all goes well I should hope to get it working by next week.

Again, thank you for all the help, hope you are all doing well.

Well, I have a few problems making an TTL UART, I need an oscilloscope first. I was looking at buying a cheap one when I realize I have all the parts to make a cheap digital scope, so that is what I am doing first.

On the other hand I am find a use for all the electronic parts I have kicking around here.