YCN-
Posts: 246
Joined: Fri Jun 10, 2016 3:18 pm

Software Serial C lib

Wed Feb 14, 2018 2:51 pm

Hey guys,

I'm building a midi sequencer / groovebox, so far so good, the sequencer part is ready and functional, but here it is, as one would know, midi baudrate is incredibly boring : 31250 baud :shock: which was classic into the 80th and is no longer...

I've a Raspberry pi 2, and with newer kernel it's no longer possible to do the trick of doing serial at a standard baud rate and change the clock frequency.

Do you know what library I could use in C in order to do software serial ? ie taking any GPIO I want and using them as classic UART. I know for sure that this is possible since it's classic and pigpio seems to do that in C. I'm looking for a clean way to achieve that and not a work around.

Thanks for your help,

YCN-

User avatar
joan
Posts: 13541
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Software Serial C lib

Wed Feb 14, 2018 4:17 pm

For software serial I think both RPIO.GPIO (not RPi.GPIO) and pigpio will do the output. As far as I am aware only pigpio will do the input.

YCN-
Posts: 246
Joined: Fri Jun 10, 2016 3:18 pm

Re: Software Serial C lib

Thu Feb 15, 2018 8:35 am

Hi,

Thanks for your answer, but I'm actually looking for something written in C, the solution to talk to the a python script doesn't really feels like a good solution to me.
My sequencer software is fully written in C, that's why I can't afford using python, even though it seems like every damned things in the py userspace is done in python ahah

jahboater
Posts: 2858
Joined: Wed Feb 04, 2015 6:38 pm

Re: Software Serial C lib

Thu Feb 15, 2018 8:46 am

YCN- wrote:
Thu Feb 15, 2018 8:35 am
Thanks for your answer, but I'm actually looking for something written in C, the solution to talk to the a python script doesn't really feels like a good solution to me.
My sequencer software is fully written in C, that's why I can't afford using python, even though it seems like every damned things in the py userspace is done in python ahah
Then pigpio is probably your best bet (it is written in C).

http://abyz.me.uk/rpi/pigpio/

See the many examples.

It should be pre-installed in Raspbian.

YCN-
Posts: 246
Joined: Fri Jun 10, 2016 3:18 pm

Re: Software Serial C lib

Thu Feb 15, 2018 9:21 am

Thanks but it seems like you can only do Reads operation, whereas I actually need to do only write :

"gpioSerialReadOpen Opens a GPIO for bit bang serial reads
gpioSerialReadInvert Configures normal/inverted for serial reads
gpioSerialRead Reads bit bang serial data from a GPIO
gpioSerialReadClose Closes a GPIO for bit bang serial reads "

I believe I will have to add a uC to pass trough the communication to the actual midi device... But it seems crazy that I can't do that simply...
Do you know if I can use a USB to serial cable at a baudrate of my choice ? Does the driver allow that?

I believe it won't also allow weird baudrate too, but I don't know?

Regards,

YCN-

User avatar
joan
Posts: 13541
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Software Serial C lib

Thu Feb 15, 2018 9:39 pm

To bit bang serial data for output with pigpio you need to use waves, e.g. from C http://abyz.me.uk/rpi/pigpio/cif.html#gpioWaveAddSerial

YCN-
Posts: 246
Joined: Fri Jun 10, 2016 3:18 pm

Re: Software Serial C lib

Thu Feb 22, 2018 1:39 pm

Oh thanks Joan, I don't really feel confortable with the wave concept. Can you explain a bit more?

Regards,

Return to “Graphics, sound and multimedia”

Who is online

Users browsing this forum: No registered users and 13 guests