Wednesday, December 11, 2013

Problem linking w/ libusb on Linux

Trying to compile the software for my weather station ( http://te923.fukz.org ) on Ubuntu 12.04.3 LTS, I ran into problems like this:

/tmp/ccPvR8eT.o: In function `te923_handle':
te923usb.c:(.text+0xe3): undefined reference to `usb_init'
te923usb.c:(.text+0x132): undefined reference to `usb_open'
te923usb.c:(.text+0x183): undefined reference to `usb_get_driver_np'
te923usb.c:(.text+0x19d): undefined reference to `usb_detach_kernel_driver_np'
te923usb.c:(.text+0x1ae): undefined reference to `usb_set_configuration'
te923usb.c:(.text+0x1f1): undefined reference to `usb_claim_interface'

te923usb.c:(.text+0x231): undefined reference to `usb_set_altinterface'

It took some time figuring out what the problem was. There were references to libusb-0.1 libusb-1.0 and fidderences in linking and calling conventions. There were references to -L for gcc. All os these failed to work.

The problem showed itself to be, that the -llib flag must come after the files that are to be linked with the library, so changing 

te923con: te923con.c te923con.h te923usb.c te923usb.h te923com.c te923com.h
gcc -Wall -lusb -o te923con te923con.c te923usb.c te923com.c

to 

te923con: te923con.c te923con.h te923usb.c te923usb.h te923com.c te923com.h
gcc -Wall -o te923con te923con.c te923usb.c te923com.c -lusb

fixed the problem, and allowed me to compile without errors.

Guess this GCC change will affect a multitude of software.

Tuesday, July 16, 2013

Short review of XCOM: Enemy Unknown

I recently bought XCOM: Enemy Unknown for my iPad (Playing on an iPad Mini), and I really love the game. Best game I have been playing for ages.

I love games like Civilization (been playing since 1991 when the first version was out) which is pure strategy and Rainbow Six which is a tactical shooter with purposeful missions. XCOM is some of the same, yet different. It is a strategy game in that you handle resources, research etc between the actual missions. And the actual missions are turn based strategy / tactical games with animation/cutscenes making it almost feel like a first person shooter. Sometime I feel too much time is wasted on the animations though.

The story line is good, and evolves through the game, all about an alien invasion force. There are different missions, some that repeat, and then 3 major events. You lose the came when enough countries pulls out from the council because they feel you don't give them sufficiently protection, and their panic level rises. You can lower panic level by doing mission in the countries, or putting satellites in orbit. You need to improve spaceships as well to shoot down UFOs.

You have different soldier classes (Rookie, Assault, Support, Heavy, Sniper) with different skills. The precision of the sniper increases with distance, so he is not too good in close quarter combat, but he can give good support from out of harms way. All other differs mostly in what weapons they can use, and their additional skills when promoted.

Personally, I save the game before the first move, as I hate it when I make stupid mistakes and some of my guys gets killed. I see each operation like a game of say Angry Birds", where I have to pass the level without anybody dying on me. Wounded is unavoidable, and OK. I try to keep secondary soldiers up to snuff, by taking one in on the not too difficult missions. Then they get promoted and assigned a class.

Most strategy sites tells you to level up 1-2 snipers as fast as possible, at least one sniper with Squadsight, Damn Good Ground, Opportunist, and In the Zone or Double Tap which can be left back and high, and provide very good support. And with disabling shot, he can help the rest bring down heavy targets too.

Wednesday, June 19, 2013

How to bring a Sipura SPA 2000 back to life

My Sipura SPA 2000 SIP ATA adapter just died after 6-7 years of continous operation.
The LED would turn on when plugged in, but the Ethernet never came up, and would never light up the LED on the switch.

Searching on the Internet, I figured out that it was likely the PSU going dead (The electrolyte in the capacitors will waporize over time). Tested with a 5V 1A PSU I had for use with a powered USB HUB, and the SPA2000 worked fine again, but the PSU got too warm for my taste. Found a 5V 2A PSU in a box, and everything is now running fine again.

I ordered a new 5V 2A PSU from China via eBay.com. $3 including shipping.

Cheap fix for a product I almost thought was dead. So remember, if things has worked a long time and stops working, it might just be capacitors having reached their expected lifetime.