Get MIDI note from USB interface on Arduino Yun - linux

I am using an Arduino Yun and a MIDI to USB interface and my goal is to read the incoming MIDI note on the installed Linux operating system.
The goal is to have the computer on the Yun read the note and send it to the Arduino which then transmits a square wave over the pins at the note played on the piano.
But I can't figure out how to read from the USB interface; the Linux system is command line only and I can't figure out a good way to read the incoming note.

There is nothing special about USB; the USB MIDI driver makes the interface show up as a normal MIDI port, which can be accessed like any other MIDI port.
If you want to write a shell script, the easiest way is probably to parse the output of aseqdump.
See Translating MIDI input into computer keystrokes on Linux? for an example.
If you want to write a C program, you have to use the ALSA sequencer API; consider using the aseqdump source code as a template.
If you just want to send the raw MIDI bytes over the serial line, you can simply read them from /dev/snd/midiC?D?.

Related

How to get the raw serial output from a serial device file without using pySerial?

I have an embedded development board connected to my Ubuntu host PC. And the board's serial port is exposed as /dev/ttyACM0 file.
I experiment with below naïve python code to read the raw serial output from the board.
with open("/dev/ttyACM0", "r") as sdf:
content = sdf.readline()
print(content)
I first let the board to output some string.
After a while, when I am sure the string output is finished, I run above script. It does print out the readable string. (BTW, it seems the serial output from the board seems to be cached somewhere.)
My questions are:
With tools like putty, I need to specify some parameters of the serial port, such as baud rate, etc. But I didn't specify anything in my script. How could it ever work?
If the serial port is outputting a stream of binary data endlessly, how to capture them lively?
Note: I don't want to use pySerial or other packages. I just want to do it from scratch.

need to send ASCII codes over Bluetooth

Just looking for a "pre-made" device that could get ASCII codes (at the same time power up the device where the codes come from) and send the ASCII string over Bluetooth,
Technically, I want a device where I can connect standard Keyboard with a USB plug, and send the the keystrokes via bluetooth,
Just wondering if there is a device already setup to do this, no time to develop,
thanks
Assuming you want to convert a USB keyboard to Bluetooth, there's a handful of options out there, like the BT-500 from handheldci.com: http://handheldsci.com/kb/
And some similar FOSS arduino version: https://github.com/juancgarcia/HID-Relay
If this is not what you're trying to do, you'll need to specify it a bit better. "send characters over bluetooth" is sadly not that simple, the bluetooth device has to identify as some type of device. That could be a keyboard (HID), however it could also be something like a serial port over bluetooth which something like a HM-05 implements.

Read digital data directly from a USB port

I use Arduino for comunication between sensors and my C# application using a serial port. Is there any possibility to access digital components directly such as Force Sensitive Resistor - Square, from a USB port?
Do I have to write a driver for that?
I drew a semi-schematic diagram to exemplify:
There isn't a way to directly read an analog sensor over USB since it's a digital bus. You need some sort of processing to convert the analog signal to digital and communicate over the bus properly.
In order to sample information from any sensor, you will need an intermediary. The Arduino uses an FTDI chip to convert UART (Serial) to USB. When you read data over this connection, you are reading it over the Serial over USB interface. My recommendation is to stick with using the Arduino or other micro controller.
If you are really bent on reading it Directly over USB (instead of through the Serial over USB converter) you would have to implement some sort of protocol in a device that supports USB such as the Stellaris Launchpad or an Atmega32U4 AKA Arduino Lenardo. You would also have to write a driver to describe how to communicate with this USB device. Unless you were able to implement it as an already known device such as a keyboard or serial port (Yep, we went full circle there).
In short, there's no already made chip that converts Analog (or Digital) values from a sensor into something any OS would natively understand. Since USB is a protocol much like IP, you're not going to be able to use discreet devices. You're going to have to use a micro-controller with a USB stack.
Again, my advice would be to pass the sensor values over USB through the existing Serial (over USB) port. This is pretty straight forward and easily reproducible without an entire Arduino.
From the looks of the force-sensitive resistor, this is an analog component; the resistance and capacitance changes with the force applied to the sensor. If you check out the FSR installation guide document there are suggested electrical interfaces starting on page 16.
I would recommend the first circuit, connect Vout to an analog input on the Arduino. From there you will need to convert from ADC counts to voltages and then use a lookup table function in the Arduino to convert from voltage to force according to Figure 9. At this point you have a variable containing the force applied to the sensor. From here you can transmit the value over the USB serial bus just like any other value. Your C# application then needs to read the serial data, and parse out the value.

PCM voice data on serial port to sound device conversion in linux

I have a telephony modem which gives voice to my interfaced application via a serial USB ttyUSB0 in 16bit PCM 8000hz. I am able to capture this data and play with audacity. I want this port to be detected as a sound device in linux (I am on ubuntu). Is it possible? Are there any other options?
I'm guessing you are using a huawei 3G modem or something similar which gives ttyUSB1 for audio. Make sure you have the serial driver binded to it. Then simply pass the port itself as a "file" for input for any program of your choice.You need root access for that.You figured out the audio settings so it must be enough.I have voice calling working in UBUNTU 11.10 with Huawei. So let me know if i can help any further.
Ok, I see it's very old question but answers helped me to get a right direction so I decided to help others.
The one way to achieve (in addition to below) what are you are
looking for is to write dynamic kernel module.
Have it register as a sound device, and check that it has a GSM
module present (which module is it exactly can be recognized in
dmesg, lsmod, or output).
Then establish communication between user space representation as a
sound card and serial usb module.
The other way is to get module that you recognized by dmesg, lsmod and extend its functionality as a sound card.
All are tricky tasks because:
in the first case you have to resolve intermodule communication at the kernel level...... which is, lets say, a little hard even if programmer has a right background in subject.
the second case is hard in that you have to deal with:
USB stack (which is little unpleasant for human beings) and
sound subsystem (which is a little burdensome because of historical issues).
Without being an experienced kernel programmer there are small chances to succeed.

LabVIEW string output

How do I send a string output from a DAQ Board (NI- USB 6259) using LabVIEW? I want to send commands such as "CELL 0" or "READ" to a potentiostat device using LabVIEW.
Thanks
The 6259 doesn't do string output. It's a data acquisition board that's intended for reading/sourcing analog voltages or sending/receiving individual digital signals. It's not a communications device.
If you're really trying to send strings to this device, you probably need something more like an RS-232 or GPIB connection.
As eaolson said a DAQ is not intended to control devices. However it is an interesting project to enter the guts of the communication protocol. Doing it with a DAQ would require to:
Identify the protocol (GPIB or RS-232)
Make your cable from the DAQ output connector
For each command, generate the waveform in LabVIEW, by using the letters' ASCII code, stop bits, etc. This is the funniest part (INMHO, but I understand it's not everybody!)
Send it (using DAQ analog write VIs, you should find many examples for this)
The oscilloscope will be your best friend

Resources