Armageddon421's Hackingblog

quickhack

ResCan – scan resistor values!

by on Feb.15, 2014, under quickhack

Well, this one was unexpected. I went to visit ST from project-insanity and he wanted to have a huge pile of unsorted resistors… sorted. Measuring with a Multimeter is unpractical and slow and reading the color codes gets tiring very quickly.

“A machine could do this!” -me

So I started writing an android app using opencv to detect the color codes. Although the camera outputs a fullHD-Stream, it has trouble focusing at low distances. Moving the phone further away results in the color rings being only 2 pixels wide, what makes it quite hard to safely detect.

I decided to use a cheap USB-Webcam with manual focus to overcome the problem. Luckily the webcam has six cold white LEDs around the lens, providing a nice constant light source. Only the automatic adjustment of exposure time sometimes causes trouble. I used java on the desktop-PC so I could reuse parts of the code from the android app.

Although I’m using opencv to grab the video stream and its tools to crop images and draw on them, the algorithm itself is a bunch of for loops. I couldn’t bother to find out how to train any classifiers. Basically all I do is separating the resistor from the white background and then detecting the “thicker thing” between the two leads. This works pretty stable, even for extremely bent leads.

The thick red line shows where the algorithm thinks the center of the resistor is, the blue lines show where the color is grabbed. Because of the specular reflections from the LEDs, there is no grabbing happening at the center line.

ResCap1

Finally, I decided that it would be nice if the tool reads out the values loudly, just the way we worked in tandem when we tried to sort them manually. I used FreeTTS, an open source pure-java text to speech implementation to achieve this.

Watch the video to see it in action!

Update: I put the project on GitHub! There is also a jar to try out! https://github.com/armageddon421/ResCan/releases

14 Comments more...

Android dead reckoning

by on Feb.13, 2014, under quickhack, Random

One of our lecturers gave us the excercise to to over the winter holidays to write an android app in qt that reads and logs sensor and GPS data, does some calculations on them and displays the refined result on a map.

Reading out GPS and sensors from within qt proved difficult, and displaying a map was also not exactly the easiest task at all. Two weeks before the deadline, he lifted the qt-restriction. Naturally, I started the project in android studio two days before the deadline.

In the videos below you can see the result. The data has been recorded with my smartphone placed in the center console of my car.

I found out we also had to do a height profile, so I hacked this together last-minute:

It was fun playing around with dead reckoning. If anyone is interested I might post about how it works or even try to implement some proper algorithms, since this is just a quick mockup rather than anything useful. For example there is no real calibration or gravity compensation of any kind.

This was also the first time I tried to use fragments in android, which proved quite difficult because I didn’t quite read up enough to understand how they work and how to deal with their lifecycles. I obviously managed to get it to work somehow, though, but it might not be exactly the prettiest solution.

Greetings,

armageddon421

Leave a Comment more...

self-made Canon EOS 300D remote release

by on Aug.04, 2011, under quickhack

Today I wanted to do some long-time exposures. Since I can only choose exposure times of up to 30 seconds, I have to use the so called “bulb” mode, which just exposes as long is I keep the button pressed. I can not hold perfectly still for tens (or tons) of minutes, so I usedTutorial (german) as an inspiration and built my own remote release trigger using a small wood piece as a base, a button and a switch, a cable with a 2.5mm jack I got from an infrared receiver and loads of hot glue to make it comfortable to hold. Have a look.

remote triggerremote trigger

This should also fit for most other cameras of the Canon EOS series, but there are some exceptions.

Leave a Comment :, , , , , , , more...

LTE USB-Stick Samsung GT-B3740 on Ubuntu!

by on Jun.05, 2011, under Projects, quickhack

Yesterday, Onny from project-insanity.org got himself a Vodafone contract for the new LTE-Mobile-Broadband-Connection that came with a Samsung GT-B3740 USB modem. It works on Windows, it works on Mac,…

So now we come to the interesting part: Can we get it to work on linux?

We got us this driver that is for the B3730, did everything the README file told us to and hoped it would work with our device… It didn’t. So we tried to find out why. Our first guess was the chatscript not initializing the modem corectly. It turned out we were right. After analyzing the USB-traffic on windows, we were able to reconstruct the AT-commands that are being sent to the modem in order to initialize it and establish the connection. We sketched it on paper. Here the pictures of it in case someone needs it for debugging. The right column are the replies that the modem sends back.

After having created the corresponding chatscript and executed it, the light turned first blue, then green and it magically connected. Executing dhclient sets everything else up.

This is how our working chatscript looks like:


ABORT 'TIME OUT' ABORT 'ERROR'
'' ATE1
'OK' AT+CSCS="UCS2"
'OK' AT+CMGF=0
'OK' AT+CHANGEALLPATH?
'OK' AT+VERSNAME=1,0
'OK' AT+VERSNAME=1,1
'OK' AT+CMEE=2
'OK' AT+CGREG=2
'OK' AT+CFUN=5
'OK' AT+CPIN?
'OK' AT+CNUM
'OK' AT+MODESELECT=2
'OK' AT+CSQ?
'OK' AT+COPSNAME
'OK' AT+CSQ?
'OK' AT+CGACT?
'OK' AT+CSQ?
'OK' AT+CSQ?
'OK' AT+CSQ?
'OK' AT+CSQ?
'OK' AT+CSQ?
'OK' AT+CSQ?
'OK' AT+CGDCONT=1,"IP","web.vodafone.de"
'OK' AT+CGATT=1

'CGACT:1,1'

For the more unexperienced folks, I have tried to mash up a little tutorial.


git clone https://github.com/mkotsbak/Samsung-GT-B3730-linux-driver.git
cd Samsung-GT-B3730-linux-driver
sh build.sh
cd option
sh build.sh
cd ..

sudo vim /etc/usb_modeswitch.d/04e8:689a
        #make sure the line "NoDriverLoading=1" has no "#" in front of it
        #also make sure that there is no file "04e8:6889" in that folder

vim chatscript.txt
#replace the content of this file with the chatscript from above


#this was the basic setup, it only has to be done once.
#from here, you can make yourself a script because
#this has to be at least executed after each reboot

sudo modprobe option    #load the default option driver to get the dependencies
sudo rmmod option        #unload it again
sudo insmod ./option/option.ko    #load the custom option module
sudo modprobe usbnet
sudo insmod ./kalmia.ko    #load the driver module for the modem

sh chat.sh    #this initializes and connects the modem using out chatscript.txt!
sudo ifconfig wwan0 up    #bring the ethernet device up
sudo dhclient wwan0        #get an ip, gateway and dns

#finally, you have to monitor the connection to prevent the serial
#buffer on the modem from overflowing

sudo minicom -o -D /dev/ttyUSB0    #just leave this open while you are connected

Voila! It should work!

You might have to adjust some values, for example /dev/ttyUSB1 instead of USB0 if you already have another USB-to-serial device. This has to be changed in the chat.sh script and the minicom command.

If you have promlems, you could also try disabling the Ubuntu network-manager and killing the modem-manager by doing


sudo /etc/init.d/network-manager stop
sudo killall modem-manager

Also remember that you might have to install minicom and usb-modechange.

Finally, a picture of me doing a ubuntu upgrade from 10.10 to 11.04.

I hope I could help you out!

Have a nice connection! See ya!

Edit:

In case you have usb-modeswitch installed and the file in /etc/usb_modeswitch.d/ is still empty or missing, you may create it with the following content:



#######################################################
# Samsung GT-B3730

DefaultVendor= 0x04e8
DefaultProduct=0x689a

TargetVendor=  0x04e8
TargetProduct= 0x6889

MessageContent="55534243785634120100000080000601000000000000000000000000000000"

CheckSuccess=20

NoDriverLoading=1

Update:

Onny from Project-Insanity.org got the new driver version running on Arch Linux x64, Kernel 2.6.39 using the following method


git clone https://github.com/mkotsbak/Samsung-GT-B3730-linux-driver.git
cd Samsung-GT-B3730-linux-driver
wget https://raw.github.com/mkotsbak/linux-2.6/Samsung_kalmia_driver-3.0/drivers/net/usb/kalmia.c
wget -O option/option.c “http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.38.y.git;a=blob_plain;f=drivers/usb/serial/option.c;hb=HEAD”
sh build.sh && sh option/build.sh
* if not grep NoDriver /etc/usb_modeswitch.conf; sudo echo “NoDriverLoading=1″ >> /etc/usb_modeswitch.conf; fi;
sudo modprobe option && sudo rmmod option (to get module deps)
sudo insmod ./option/option.ko
sudo modprobe usbnet
sudo insmod ./kalmia.ko
wget -O chatscript.txt http://onny.project-insanity.org/files/chatscript_vodafone.txt
sudo sh chat.sh
sudo dhcpcd wwan0
minicom -o -D /dev/ttyUSB0

15 Comments :, , , , , , , , , , , , , , , , , , , more...

Pointy – Revived Laserpointermouse-project

by on Apr.01, 2011, under Projects, quickhack

Ages ago, I had a project that used a webcam to track a laser pointer on a wall and control the mouse cursor. When using a strong laser pointer, this even worked together with a projector. Since the project is very old and will not compile (c++) any more, I revived the project by doing a little bit of python coding. There is no calibration yet and the camera used was way to bad, but somehow I got it working, under certain circumstances (the picture has to be white enough for the camera to automatically turn the brightness down far enough etc).

Here are some proof of concept videos:

Leave a Comment :, , , , , , , , , , more...