notes on javascript, linux, and more

4.28.2008

Samsung SGH-T509, T-Mobile GPRS, Bluetooth DUN on a Debian GNU/Linux Laptop

My Setup:
  • Asus EeePC with Debian GNU/Linux Lenny/Sid, custom real-time patched 2.6.23 kernel
  • Bluetooth enabled T-Mobile Samsung SGH-T509
  • Zoom USB bluetooth adapter
  • GPRS Internet (T-MobileWeb aka T-zones)
  • installed packages: bluetooth ppp gnome-ppp
Technically speaking, any Bluetooth phone with DUN support should work, but the breadth of hackery here is in the details. For instance, with my phone, doing a scan with 'hcitool scan' produced no results for my t509, although it should have. Once I successfully paired my phone and laptop, I found my DUN channel mostly through guesswork (its on channel 1). The only reliable way I was able to get my phone to dial was by using a patched version of gnome-ppp for ubuntu, run as the root user.

Googling around turned up Using the Palm Treo 650 with Debian GNU/Linux and Modem Script for Samsung t509. Looking through scripts on those pages, I was able to piece together the initialization strings I needed to open a GPRS connection.

My /root/.wvdial.conf is as follows:


[Dialer Defaults]
Modem = /dev/rfcomm0
ISDN = off
Modem Type = USB Modem
Baud = 115200
Init = ATX3
Init2 = AT
Init3 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Init4 = AT&K3
Init5 = AT+CGDCONT=1,"IP","WAP.VOICESTREAM.COM"
Init6 =
Init7 =
Init8 =
Init9 =
Phone = *99***1#
Phone1 =
Phone2 =
Phone3 =
Phone4 =
Dial Prefix =
Dial Attempts = 1
Dial Command = ATM1L3DT
Ask Password = off
Password = guest
Username = guest
Auto Reconnect = off
Abort on Busy = off
Carrier Check = off
Check Def Route = off
Abort on No Dialtone = off
Stupid Mode = on
Idle Seconds = 0
Auto DNS = on
;Minimize = off
;Dock = on
;Do NOT edit this file by hand!


To connect just create a menu entry for 'gksudo gnome-ppp' and you should be all set. You will need to use a web proxy to surf the web, and most ports are blocked. Still, it is useful to have internet wherever you have cell phone coverage. T-Mobile has a proxy you can use, google around. If you don't have a /dev/rfcomm0, this may help: http://pratyeka.org/rfcomm/

References:

http://howtoforge.com/connecting-gprs-from-ubuntu-gutsy
http://easyconnect.linuxuser.hu/

4.20.2008

Netcat, the network swiss army knife

What is netcat?


From the official GNU page:


Netcat is a featured networking utility which reads and writes data across network connections, using the TCP/IP protocol.


Have you ever been in a bind, where you need to transfer a file between two networked computers, but neither of them has any file transfer services running? You could install and configure SMB, NFS, or FTP, but if you just need to transfer a few files occasionally, or you are working with very limited system resources, perhaps it is best to just use netcat.


However, netcat is not just a file transfer utility. It’s beauty lies in it’s simplicity; you can use netcat to pipe data across a network, in the exact same way that you can pipe data on a Unix or Windows shell. This makes it extremely simple for novice scripters to transfer any kind of data over the network, even continuous streams of data.


Here’s how to send a file to hostname or IP address ‘foo’, for some port number ‘bar’.

On ‘foo’, run this command:


nc -lp bar > /path/to/save/file/to


Then on the file sender:


cat /path/to/original/file | nc foo bar


So, what else can you do with netcat? Here’s a fun example: on some machine with a microphone connected, and mixer levels set accordingly:


cat /dev/dsp | netcat -d -h foo -p bar


And then on some other machine, ‘foo’, with the firewall configured to allow TCP connections to port ‘bar’:


netcat -lp bar > /dev/dsp


What does this do?

It streams your microphone input to the speakers of ‘foo’. At least, it should in theory. I don’t have a way to test it right now, but let me know if it works for you. It may require slight modification. Careful that the speakers and microphone aren’t in the same room, or you’ll get feedback!


Here’s another fun example: a very tiny webserver (modified example from http://www.stearns.org/doc/nc-intro.current.html).


printf "Content-Type: text/html\n\n" > ~/mywebpage.html

echo 'hello world' >> ~/mywebpage.html

while true ; do cat ~/mywebpage.html | nc -l -p 80 | head –bytes 2000 >> /tmp/requests ; date>> /tmp/requests ; done


Of course, I can’t test that right now either…


Well, hope you had fun, and I hope it worked. Let me know if you found any modifications that were necessary to get things to work right. Cheers.

4.16.2008

synthesizer programming pipe dreams

I have a Nord Modular synthesizer, by Clavia. It is really a fantastic synthesizer; 4 DSPs and there is a nice GUI to create your synth patches with.

There are a plethora of software programs that do the same thing, such as SynthEdit, OpenSoundWorld, MaxMSP, and PureData. I've used them all, and I constantly find myself wishing that there was a more powerful sequencer module built-in to all of these synthesizers. I don't like using multiple programs to make music (sequencer/tracker, audio recording, synthesizer, etc), because I find all the switching modes to be distracting. I like the MSP and PD approach of building it all from scratch and keeping it all together, but the interface is very important to me, and the one thing I don't like to mix are the controls in the same place as the "code behind".

So, early in my computer science career, I decided to write my own modular synthesizer, with a heavy emphasis on the sequencer. First, I played around with C++, then I learned Java, and I tried that, but neither of those languages really seemed very nice for creating a modular synthesizer. I really loved the Scheme programming language, and thought that its functional style and emphasis on tail-recursion would be ideal for DSP and modularity. However, I didn't want to have to build my own MIDI and audio libraries from scratch, and I wasn't a good enough programmer to figure out how to write a foreign-function-interface (once I started mixing C pointers in with Scheme, I just got confused). So, along comes Python. Python has extensive libraries, many related to MIDI, audio, and music, and it has a nice, elegant style somewhat reminiscent of Scheme. I am looking into PySndObj and Csound right now. I'll update here as things progress, if they do.

4.08.2008

unix one-liners: sorted filesystem usage

i have a total storage capacity of 6gb in my laptop, so its often necessary to do a little housecleaning. the best way I've found to do this, so far, is to get a list of the directories with the highest disk usage, and sort it for easy viewing. from there, I might see some stray files I don't need anymore that I can dispose.

sudo du -c / | sort -g > sorted


"sudo du -c /" will recursively get directory disk usage for the entire filesystem. I pipe that into "sort -g" which does a generic numeric sort, and then I pipe that into a file called "sorted" which I can then look through at my convenience.

4.01.2008

april fools prank: 'when doves cry' on all the office printers' display panels

#!/bin/bash

doves=( "Dig if u will the picture" "Of u and I engaged in a kiss" "The sweat of your body covers me" "Can u my darling" "Can u picture this?" "Dream if u can a courtyard" "An ocean of violets in bloom" "Animals strike curious poses" "They feel the heat" "The heat between me and u" "How can u just leave me standing?" "Alone in a world thats so cold? (so cold)" "Maybe Im just 2 demanding" "Maybe Im just like my father 2 bold" "Maybe youre just like my mother" "Shes never satisfied (shes never satisfied)" "Why do we scream at each other" "This is what it sounds like" "When doves cry" "Touch if u will my stomach" "Feel how it trembles inside" "Youve got the butterflies all tied up" "Dont make me chase u" "Even doves have pride" "How can u just leave me standing?" "Alone in a world so cold? (world so cold)" "Maybe Im just 2 demanding" "Maybe Im just like my father 2 bold" "Maybe youre just like my mother" "Shes never satisfied (shes never satisfied)" "Why do we scream at each other" "This is what it sounds like" "When doves cry" "How can u just leave me standing?" "Alone in a world thats so cold? (a world thats so cold)" "Maybe Im just 2 demanding (maybe maybe Im like my father)" "Maybe Im just like my father 2 bold (ya know hes 2 bold)" "Maybe youre just like my mother (maybe youre just like my mother)" "Shes never satisfied (shes never never satisfied)" "Why do we scream at each other (why do we scream why)" "This is what it sounds like" "When doves cry" "When doves cry (doves cry doves cry)" "When doves cry (doves cry doves cry)" "Dont cry (dont cry)" "When doves cry" "When doves cry" "When doves cry" "When doves cry (doves cry doves cry doves cry" "Dont cry" "Darling dont cry" "Dont cry" "Dont cry" "Dont dont cry")

#55 for doves
while [ 1 ]; do
for (i=0;i<55;i+=1) {
./hpsetdisp.pl 10.9.100.1 \"${doves[i]}\"
}

This will output the contents of the 'doves' array to the LCD panel on an HP printers in my office. Just swap out the IP address for the IP of some HP printer in your office, and run the script. You can do it from cygwin for windows if you don't have any unix boxen. There was a problem with some of the printers, they would error out after a few minutes, I think the memory was filling up too fast maybe? Who knows. It was fun while it lasted. Maybe I'll work that out for next April.

Of course unix or not, you'll still need bash, perl, and the script at http://kovaya.com/perl/show.cgi?program=hpsetdisp.pl
put the perl script in the same directory as the bash script.

My thanks to the writer of hpsetdisp.pl.

About Me

My photo
chicago, il, United States
I'm a software engineer by profession.

Labels