Using a Raspberry Pi to create Usb-to-multiple 3.5mm converter? - python

I'm excited. I'm a long-time lurker here at SO, but I've never posted. Here goes!
I'm trying to develop a device that would connect to a host RPi through (preferably) USB, and would have multiple 3.5mm jack outputs. The goal, ultimately, is to get the device to use a standalone program that, when a button is pressed (keyboard, or other external input), a specific sound (or set of sounds) would go through a single 3.5mm output. Now, I understand that there's going to (most likely) have to be an external box, and I also realize that I'm in above my head, but I'm trying to create this as more of a hobby and as a learning experience.
Basically, the way it would go is that the user would set which inputs triggered which outputs beforehand on the custom software in the RPi. The input would then trigger that ouput then await a new signal. I figure I'm going to need to also build a physical box to house the amount of 3.5mm jacks I want (i figured 3-5.)
So, where do I need to start? I don't need a guide on how to do this, more of a step in the right direction. From what I can discern, there's not anything out there that does this. If there is, please show me and I'll get that instead. I've done a lot of googling on this, and I'm thinking that I'll use Raspbian on the Rpi, and code the software using Python. I know I'll also need to build a driver so that the external box and the RPi can communicate. Lastly, I assume that I'll need some type of circuitry for the external box. That's where it gets hairy to me. I've never dealt in physical I/O except for a bit of modding. Where would I start my search there?
Any help at all is appreciated, and thanks for reading this huge post. Thanks!!!!!!!!!!!!

Related

PyUSB Stop Dymo scales from shutting down automatically

I am using a Dymo USB scale with PyUSB and everything is really great apart from the scale's automatic shutdown after three minutes. I would like to keep it running as long as my python program is running. Is there any way to do this using python?
I am new to PyUSB and have followed this tutorial successfully so far: http://steventsnyder.com/reading-a-dymo-usb-scale-using-python/.
The auto shutdown can be disabled manually as said here:
http://www.manualslib.com/manual/472133/Dymo-S100.html?page=7
but this must be performed every single time which is a problem.
Many thanks in advance for any suggestions!
As Ignacio said, there doesn't seem to be any computing way to do this. We eventually managed to stop the automatic shutdown by wiring a timer directly to the button which changes the units mode from grams to ounces. "Pressing" this every few seconds prevents the shutdown, and a little bit of extra coding allows for reading the mass from either mode correctly.
Not as simple a solution as I'd hoped for, but perhaps the idea will help anyone with a weirdly-specific problem similar to this.
Here is a hardware description to open/modify and code to toggle the scale button of DYMO (to avoid auto-shutdown)
https://learn.adafruit.com/data-logging-iot-weight-scale/code-walkthrough

How to read a tag from PN532 in Python?

I want to experiment with the PN532 that comes connected with an arduino UNO. I have never touched anything similar, and in fact it took me quite a few tries to be able to play with LEDs on another arduino board I have.
Can someone provide me with a concrete example of reading data from the pn532 when I use a tag or card on it in Python?
Take a look at https://github.com/HubCityLabs/py532lib. The standard library is in C, somebody wrote a Python wrapper for the C library that you can use.
I did found a way that might be partially correct. Since Eugenes' answer does not provide a definitive way that we know will work, it cannot be considered a full answer so I will most probably accept this one if nothing else changes.
First of all since the PN532 does not continuously monitor for signals and emits data, we will have to program it the usual way in order for it to behave according to what we want to achieve.
This can be done using the same software that you program any other Arduino device.
Make sure you have chosen the correct port from the tools menu. If you don't know which port is that, in windows go to Start>All Programs>Accessories>System Tools>System Information>Components>Ports>Serial. For Linux going to /dev/serial/by-id should do.
Then I would recommend using the examples provided by the manufacturer here. Make sure you choose the right connection type or else you will see no data coming from the device (Most probably you will want I2C).
Once that is done, and your device emits data each time a tag is used on it (check with a serial terminal configured at 115200 Baud rate) then you are ready to start working with python.
Again I recommend this module to read your data from the serial port. It even comes with a ready to use example of a wxWidgets terminal to read your data from the PN532. If of curse you use another python library and you think its better do say so in the comments.

Python over a network share

So I have tried to find a answer but must not be searching correctly or what I'm trying to do is the wrong way to go about it.
So I have a simple python script that creates a chess board and pieces in a command line environment. You can in put commands to move the pieces. So one of my co workers thought it would be cool to play each other over the network. I agreed and tried by creating a text file to read and write to on the network share. Then we would both run the script that reads that file. The problem I ran into is I pretty much DOS attacked that file share since it kept trying to check that file on network share for a update.
I am still new to python and haven't ever wrote code that travels the internet, our even a simple local network. So my question is how should I go about properly allowing 2 people to access this data at the same time with out stealing all the network resources?
Oh also im using version 2.6 because thats what everyone else uses and they refuse to change to new syntax
You need to use the proper networking way. It's not quite hard for simple networked program like yours.
Use the one from the Python's stdlib http://docs.python.org/library/socket.html (also take a look at the examples at the bottom of the page).
First off, without knowing how many times you are checking the fle with the moves, it is difficult to know why the file-share is getting DoS-ed. Most networks and network shares these days can handle that level of traffic - they are all gigabit Ethernet, so unless you are transferring large chunks of data each time, you should be ok. If you are transferring the whole file each time, then I'd suggest that you look at optimizing that.
That said, coming to your second question on how this is handled at a network level, to be honest, you are already doing it in a certain way - you are accessing a file on a network share and modifying it. The only optimization required is to be able to do it efficiently. Even over the network operations in a concurrent world do the same. In that case, it will be using fast in-memory database storing various changes / using a high-scale RDBMS / in the case of fast-serving web-servers better async I/O.
In the current case, since there are two users playing the game, I suggest that you work on a way to transmit only the difference in the moves each time over the network. So, instead of modifying the file over the network share, you can send the moves over to a server component and it synchronizing the changes locally to the file. Of course, this means you will need to create a server component that would do something like this
user1's moves <--> server <--> user2's moves . Server will modify the moves file.
Once you start doing this, you get into the realm of server programming / preventing race conditions etc. It will be a good learning experience.

citrix GUI automation or packet injection?

most of my job is on a citrix ICA app.
i work in a winsows enviroment.
among other things, i have to print 300 reports from my app weekly. i am trying to automate this task. i was using a screenshot automation tool called sikuli, but it is not portable form station to station.
i thought i might be able to inject packets and send the commands on that level. i was not able to read the packets i captured with whireshark or do anythin sensable with them.
i have expirence with python and if i get pointed in the right direction, i am pretty sure i can pull something off.
does anyone have any ideas on how to do this (i am leaning towards packet injection aat the moment, but am open to ideas).
thanks for the help,
sam
after a lot of research, it cant be done. some manipulation like change window focus with the ICA COM object.

Using python to control a phone with bluetooth

I would like to know if there are any API's for python to programmatically control a phone, like starting and ending calls, but also to record conversations.
I would also like to use the Headphones and Mic of the computer to talk over the phone.
Any info would be great, I tried googling for something, but nothing useful came up.
Be careful when using PyBluez! The results will actually depend on the BT-USB dongle you are using. Depending on the hardware(the BT chip in there), PyBluez will use one or another BT stack - for example there was one from WIDCOMM. Results will vary, as PyBluez is actually wrapping around those stacks - all of which are far from complete.
So, when you have a working project, be sure to know what actual BT stack you were using :)
For Python audio stuff, you could try this.
PyBluez is an effort to create python wrappers around system Bluetooth resources to allow Python developers to easily and quickly create Bluetooth applications.
Unfortunately I've not found a page dedicated to its features, but it could be a good starting point, whether everything you need is in its feature set, or if you could build your application upon it by extending it.
http://code.google.com/p/pybluez/

Categories

Resources