AC3-Divx on my PPC

As I’ve written in the review of my hx4700 PDA, the thing really shines when it comes to displaying XViD videos.

The single big problem about Betaplayer is that it lacks support for decoding AC3-streams. This is bad, as most of my movies have an AC3 audio stream (always looking for the optimum quality). So I was on the lookout for a solution.

I quickly found PockedDivxEncode which comes with nice presets for encoding videos for a PocketPC

The problem was that the current version always insists to recoding the video stream when converting the video file, thus reducing the overall quality (it’s no use compressing two times) and needing a long time to do its job (about 50% realtime or slower. Haven’t tried).

Then, on the download-page I found this not-so-visible link to the the current beta test version, which has – under “Advanced Settings” an option to leave the video stream alone and just work on the audio stream.

Using this configuration, recoding just the AC3 stream becomes possible. As it’s leaving the video alone, it’s reasonably fast too – about 4 times realtime on my thinkpad.

This is a usable solution until Betaplayer gets AC3-Support.

SQLite on .NET CF

SQLite just doesn’t stop to amaze me. First, we got it to compile on our small ucLinux based barcode scanner where it not only works flawlessly, but extremely fast too.

Now I thought about using SQLite in a little PocketPC application I intend to write using the .NET compact framework. This after some very bad expirience with SQL Server CE

  • There is no useful frontend to modify the data in the sdf-File: There is no tool for the desktop (besides using SQL-Server and then replicating the data to the device which I actually got to work this march or so, but it was a major pain in the ass to set up and is no solution to me. I mean: Why should I install a whole SQL-Server just to get some test-data to a smart device?) and the little frontend on the PocketPC suffers from the small screen and the lack of a keyboard.
  • Despite everyone claiming it’s fast, it isn’t (though this certainly is relative. I’m sure, the marketing departement of MS is still conviced that it’s fast). Where some operations may be, others are not. Searching for strings is an example of extreme slowness.
  • Starting an application using SQL Server CE takes about a minute on a usual 400 Mhz PocketPC. Way too long to be used in production with customers.

So, using a leightweight local SQL-engine which is fast even on a 66 Mhz CPU without MMU sounded quite appealing to me. Just: How much work would it be? How well would I be able to integrate SQLite into .NET?

Knowing about the lack of features in P/Invoke on the compact framework and knowing that the SQLite API uses callback functions, I feared the worst, but fortunately, I googled before getting to work.

So, I found this project.

They provide you with a full-fledged ADO.NET driver for SQLite, so you can use all the database classes and components you are used to, while still profiting from the advantages of SQLite

Compiling it was easy (while they provide pre-built binaries of sqlite.dll and the P/Invoke-Wrapper sqlite_wrapper.dll, they do so only for ARM and the desktop version of Windows for x86, so if you want to use the emulator for developement, you have to build those two DLLs yourself – using eVC4) and a quick look (it’s already late now – I got up more than 17 hours ago, so I’m quite tired now) using the sample project here was quite successful: The application started (instantly, no wait) and displayed the data inside the SQLite-File.

So, the speed-problem is solved. What about the frontend? While I don’t know any Windows GUI frontends for SQLite (though I know they exist), I have already worked with the SQLite ODBC driver (it’s funny to think of that: Usually ODBC-drivers are just a middleware between the Application and the dtabase, but in case of sqliteodbc, the database engine is linked into the ODBC-driver. Strange) and of course the command line tool and the PHP extension. So for my purposes, I’m going to create the database using a PHP-Script on Linux and copy the .db-File to the PocketPC. As seamless as possible. No replication, no installation of servers, no nothing. Just plain old copy.

SonyEricsson, IMAP, Exchange

Since we switched to Exchange I’ve been unable to get my Email from my SonyEricsson-phones (first T610, then Z600 – talk about buying too many mobiles per time unit ;-). Every time I tried to connect, I immediatly got a Server not found

Today I’d had enough. This must be fixed, I told myself and set to fix it. And as the category for this enty is “Solutions”, I actually did solve it.

A quick check with netcat on the firewall (after turning off the port forwarding rules) revealed that it’s not actually a connection problem I was running into: The phone connected fine. So it must be something with Exchange…

The event log on the server revealed nothing at all. As always with Microsoft products. Those messages are either not there or completely ununderstandable.

Next I tried to set the server to maximum logging (Exchange-Manager, right click on your Server, Properties, Tab “Diagnostics Logging”, IMAP4Svc). The result were two entries in the event log: Client XXX connected, Client XXX disconnected. Extremely helpful. Nearly as helpful as the “Server not found” my cellphone was throwing at me (see note below).

I noticed that this isn’t getting me anywhere, so I went getting the cannon to shoot sparrows with: I’ve downloaded Ethereal and listened to the conversation my phone is having with exchange:

S: * OK Microsoft Exchange Server 2003 IMAP4rev1 server version x.x (xxx) ready.
C: A128 AUTH xxxx xxxx
S: A128 BAD Protocol Error: "Expected SPACE not found".

(I won’t ask, why the phone isn’t checking the capabilities first before logging in. This is not what I call a clean impementation)

Not very helpful either. At least for me, knowing the IMAP-RFC just enough to understand what the A128 stands for (it’s a transaction number which allows for asynchronous command execution. The server prefixes answers to commands with the number given by the client), but not much else. So I had to do something else: Logging in with Mozilla Thunderbird, where I had no problems. After one failed attempt where I forgot to turn off SSL (…), I got this:

S: * OK Microsoft Exchange Server 2003 IMAP4rev1 server version x.x (xxx) ready.
C: 1 capability
S: * CAPABILITY (...) AUTH=NTLM
S: 1 OK CAPABILITY completed.
C: 2 login "xxx\xx" "xxx"
S: 2 OK LOGIN completed.

(now that I’m reading through this (still without having read the RFC): Isn’t the server lying here: It just tells to be acceping NTLM-Auth, but Mozilla seems to ignore that and using AUTH=LOGIN to log in which the server accepts too. Enlighten me!)

Aha! We seem to be having quoting issues in the phone. Good. Even better: The issue seems to be that the phone does no quoting at all, which is fine because then we can do some quoting in the preferences-screen

After one failed attempt with two spaces after the username in the LOGIN-Line which was fixed by removing the somehow added trailing space in the phone’s username-field, I actually got it working. Yes. I’m reading my mail with the phone. It did work!

So, if you are having problems connecting to an Exchange-Server using SonyEricssons Phones, do the following:

  • Enter the username as "DOMAIN\username" (with quotes). Look that there are no spaces before the first and after the last quote.
  • Enter the password as "password". Include the quotes too and remove spaces that may linger aroung

In other words:

  • Escape -es with anoter one of them: -> \
  • Put username and Password in double quotes (“)

Dann klappt’s auch mit dem Nachbarn! (from a stupid german commercial. Forget it if you don’t understand it)

One final note: <rant>Everything would have been so much easier if only there were more usefil error messages involved. While I completly understand that the designers of the software don’t want to overwhelm their users and thus create seemingly simple messages, they should absolutely provide a “Details”-Link somewhere where the whole message can be read. Granted. Cellphones are limited, so in a way, I can accept the message I got there. What I can not accept is the way Exchange loggs the errors it occurs. Why on earth doesnt’ a protocol error getting logged when logging is set to “Maximum”?</rant>

WinInet, Proxies and NTLM

For quite some time now I heard about customers telling me that PopScan seems to be having problems with proxy servers using NTLM authentication. I knew that and I told everyone that this is not supported.

But I could not understand it: Why did it not work. I mean, I went from my own HTTP-Routines to WinInet just to be able to use the system-wide proxy server settings and connections

When using WinInet and INTERNET_OPEN_TYPE_PRECONFIG with InternetOpen, the whole thing is supposed to just work – as long as IE itself does work. But in my application this wasn’t the case and I had no idea why. As soon as NTLM was enabled at the proxy, I was just getting a 407 HTTP_PROXY_AUTHENTICATION_REQUIRED status from the proxy, despite the correct password being used

MSDN was of help (taken from the documentation of InternetOpenRequest):

If authentication is required, the INTERNET_FLAG_KEEP_CONNECTION flag should be used in the call to HttpOpenRequest. The INTERNET_FLAG_KEEP_CONNECTION flag is required for NTLM and other types of authentication in order to maintain the connection while completing the authentication process

I’ve added this flag (and some more – now that I already was at it), recompiled, tested and -yes- finally it does what it should: It works just out of the box. No more 407, no more entering password for the users. One more thing that switched its state from “not supported” to “supported and working splendidly”.

This is with a NTLM-enabled Squid Proxy, but it should work with Microsoft ISA too.

RAM doubler ;-)

I have a server (running gnegg.ch) with 1.5 GBytes of RAM and I’m running Gentoo Linux (another candidate for my all-time favourites list, but it’s still too soon for that. I’m only working with it for a little bit more than one year). And as I wanted the thing to be as secure as possible, I created a kernel from scratch without module support.

What I’ve always asked myself is why the heck “free” just lists 896 Mbytes of available memory:

galadriel root # free -m
             total       used       free     shared    buffers     cached
Mem:           885        193        692          0          6         69
-/+ buffers/cache:        117        768
Swap:          976          0        976

At first I had a BIOS problem in mind, bit after having seen GRUB recognizing the whole amount of memory, I came to the conclusion that there must be some problem in the kernel

As 2.6 is still quite new, I waited for the next gentoo-dev-sources to be released which happened somewhere around today. With the new kernel the problem still existed, so I dug deeper

dmesg output something like this in its first lines:

Warning only 896MB will be used.
Use a HIGHMEM enabled kernel.

Though I misread the second line as a status message (stating that HIGHMEM is being used) instead of a request, I entered the above message to Google Groups and found out that the second line indeed is the solution to the problem

In Processor type and features, set High Memory Support to 4GB and recompile your kernel.

What I don’t understand: I’m having this problem with 1.5GB of RAM and this option seemed to me like talking about 4 GB. But Google was helpful like most of the time, enabling me to virtually double the available RAM

galadriel root # free -m
             total       used       free     shared    buffers     cached
Mem:          1520        333       1186          0         12        158
-/+ buffers/cache:        162       1358
Swap:          976          0        976

Nice! Isn’t it?

Update: For those that have not yet noticed it: The title of this entry does hint at products like this, though this one is at least honest in its description.

Eclipse, CVS and putty

I’m a really big fan of Eclipse. This Java-IDE has many great features I have never come across in other IDEs so far. The new context based syntax-highlighting comes to mind (it analyzes your sourcecode and can – for example distinguish between local variables and constants)

Actually, it’s only because of Eclipse that I now can write fairly good Java code. The thing was incredibly helpful during my first struggle to get something to work, so I made quite some progress in a quite small timeframe.

There is one thing though, I never got to work: CVS integration

I’m using CVS strictly over SSH, with the help of Putty, Pageant and Public Key authentication. Despite the fact I’ve entered the correct settings for the “ext” method (using Puttys plink.exe as CVS_RSH) in Eclipse, it never worked (it failed with various messages)

Of course there is the new extssh-Method, but this is non-standard. Where I can access the CVS-Server using extssh from eclipse, it does not really help because then the command line tools and TortoiseCVS stop working because they don’t understand extssh

Finally I found the solution: Even though it doesn’t make sense, you have to enter “cvs” under CVS_SERVER in the CVS-Settings. I don’t know why. It’s just that way. So to use Eclipse together with the command line tools and Tortoise to access the CVS-Repository from the same working copy, this is what you have to enter under Window/Preferences/Team/CVS/Ext Connection Method:

CVS_RSH yourfullpathtoplink.exe
Parameters {user}@{host}
CVS_SERVER cvs

Then you add a repository in the repository-view using the following settings:

Host your.host.name
Repository path /path/to/repos
User username
Password empty
Connection type ext

Before you finally click “Finish”, open up a command line window and log in to your CVS-Server using plink:

plink user@host

Maybe you are asked to store the host key in plinks database. Do so. Then make sure that you can login without a Password-Request popping up (Pageant must be running, your key must be loaded and authorized on the server). If that works, click “Finish” in Eclipse.

Bluetooth driver nightmare

Another post around bluetooth – one I wanted to do for quite some time now, but I have not come around to yet.

As you know, Microsoft will bring its own Bluetooth-Implementation to Windows XP with Service Pack 2 (this and the better WLAN support are two strong reasons for me wanting to install it, but the current RC1 does not work with Delphi’s debugger – I hear, this is fixed in RC2 to be released somewhere in June). What you may not know is that there is some Post-SP1-Fixup floating around that already has rudimentary BT support. I think, it initially came with Microsofts Bluetooth Accessories (Keyboards and Mice).

The Problem with this rudimentary support is that it is not compatible at all with the WIDCOMM-Stack, which provides far more functionality that this MS-thingy does.

The problem gets even worse because this Fixup pack seems to be integrated in quite some OEM preinstallations these days, even if the devices themselfes come with a WIDCOMM stack

I came across this problem with two thinkpads: Initially they have BT disabled. The official way to get it enabled is to first install the Drivers provided by IBM (the WIDCOMM-Stack) and then Press Fn-F5 and click on “Enable” in the bluetooth section. What then happens is that Windows detects the (USB-, though it’s internal hardware, it’s still USB) device and installs its rudimentary support.

The Widcomm-Tools never get to recognize the Bluetooth device – the Icon in the tray stays red. You are locked down to the limited (limited as in virtually no functionality at all) functionality of this Microsoft upgrade

The clou: I did not know this and the IBM-Support I’ve called could not help me either.

So, what’s the solution? How to recognize this problem when it happened?

Recognizing is simple: If the BT-Icon is red despite bluetooth being enabled, this may be the problem. If you want to be sure, open Control Panel / System / Hardware / Device Manager and right-click on the BT-Drvice. Select properties. If Manufacturer is Microsoft, you ran into the trap.

So… how to fix it then?

In the window described above, go to the drivers-Tab, select Update Driver. Then follow these steps:

  1. Install from a list or specific location
  2. Don’t search.
  3. Have Disk
  4. Enter c:Program Files<WIDCOMM Installation dir>bin
  5. OK
  6. Ignore the warning about drivers not being signed
  7. Complete the installation.

Sometimes you must reboot, sometimes not. But now the Widcomm software will recognize the drvice and you will have access to the full functionality

Quite simple – as soon as you have found out what the problem is

Another unobvious Windows problem

I have quite a lax administration policy concerning our network which is possible as long as we don’t have that many machines and employees: I for myself do not place many restrictions in choice of hardware and OS on our employees. They should work with whatever they want. Only restriction: The OS must be multi-user capable (means: no Windows 9x) and if the employee wants access to our file-server it must somehow support the SMB protocol.

Lukas, on the other hand, adds another requirement to the list above: The system must somehow provide support for our exchange based groupware. This can be native access or via the web interface.

So yesterday, someone wanted to add his computer to our network. It’s a IBM Thinkpad running Windows 2000 in a highly tweaked installation which should be preserved at all costs. Every other administrator would insist that at least the corporate configuration would be enforced, but I don’t care and put the users satisfaction above all easement for my task, so I let him keep his setup, but suggested him to join our Windows domain to make his life easier (no logging in to our fileserver, better exchange-support (remember: Lukas’ condition).

After some initial problems with the installed personal firewall (have I told you that I hate them? Yes I have), I went on and tried to join our Windows 2003 domain. After quite a long waiting time, the only thing I got was “Access Denied”. A quick look to the server’s event log showed nothing but success-messages.

Googling did not help (much), but told me about a certain netsetup.log windows is supposed to create on the client (it’s in %windir%Debug. Here’s the log I got:

03/30 16:19:28 -----------------------------------------------------------------
03/30 16:19:28 NetpDoDomainJoin
03/30 16:19:28 NetpMachineValidToJoin: 'THINKPAD'
03/30 16:19:28 NetpGetLsaPrimaryDomain: status: 0x0
03/30 16:19:28 NetpMachineValidToJoin: status: 0x0
03/30 16:19:28 NetpJoinDomain
03/30 16:19:28 	Machine: THINKPAD
03/30 16:19:28 	Domain: office.sensational.ch
03/30 16:19:28 	MachineAccountOU: (NULL)
03/30 16:19:28 	Account: office.sensational.chpilif
03/30 16:19:28 	Options: 0x3
03/30 16:19:28 	OS Version: 5.0
03/30 16:19:28 	Build number: 2195
03/30 16:19:28 	ServicePack: Service Pack 4
03/30 16:19:28 NetpValidateName: checking to see if 'office.sensational.ch' is valid as type 3 name
03/30 16:19:28 NetpValidateName: 'office.sensational.ch' is not a valid NetBIOS domain name: 0x7b
03/30 16:19:28 NetpCheckDomainNameIsValid [ Exists ] for 'office.sensational.ch' returned 0x0
03/30 16:19:28 NetpValidateName: name 'office.sensational.ch' is valid for type 3
03/30 16:19:28 NetpDsGetDcName: trying to find DC in domain 'office.sensational.ch', flags: 0x1020
03/30 16:19:43 NetpDsGetDcName: failed to find a DC having account 'THINKPAD$': 0x525
03/30 16:19:43 NetpDsGetDcName: found DC '\durin.office.sensational.ch' in the specified domain
03/30 16:19:43 NetUseAdd to \durin.office.sensational.chIPC$ returned 5
03/30 16:19:43 NetpJoinDomain: status of connecting to dc '\durin.office.sensational.ch': 0x5
03/30 16:19:43 NetpDoDomainJoin: status: 0x5

Not so useful besides: NetUseAdd to \durin.office.sensational.chIPC$ returned 5

As the last entry was something about a status 0x5 and the error was “Access Denied”, I figured that this “returned 5” must mean “Access Denied” too.

A quick try to access the server showed me that I was right: I could not access any share – my password was not accepted (besides the server’s security log telling me otherwise).

Finally the guy owning the noteook had an idea: He has disabled Windows 2000’s packet signing and encryption via Administrative Tools/Local Security Policy. Enabling it and rebooting finally did the trick. When asked why he did so he said that it would greatly speed up access from a PC running Windows 98…

What did I learn: Maybe my policy is a bit too lax and if keep it, I should at least not try to fix problems I’m getting with it (it would have worked perfectly well without joining the domain)
What do you learn: If you have the same problem, here’s the solution. And this is what this blog is for.

T610/Z600, Outlook, MobileAgent and Bluetooth

If you own either a T610 or Z600 mobile phone, you may know of floAt’s Mobile Agent a not-so-stable but even more powerful tool for accessing the phone from your PC. Sending SMSes, Managing contacts, even getting a popup windows when somebody calls you – everything is possbible.

Everything but synchronizing with outlook. There’s just some kind of CVS export for your contacts, but this is very uncomfortable to handle. The bluetooth sync-profile the Widcomm software provides would do the trick, but I’ve many more contacts in outlook than there’s space on the phone. So I need a way to specify which contacts to synchronize.

The software that comes from ericsson, XTNDConnect PC, has support for filters (I’ve created a category T610 and I’m syncing only contacts whithin this category), so would be doing the job.

Unfortunatly, this Ericsson PhoneMonitor-thing which XTNDConnect relies on is slightly incompatible to MobileAgent – either the phone is not detected or MobileAgent loses its connection (which locks my workstation because I’m using the proximity detection). I’ve never succeded in finding a way to reproducibly use both programs concurrently.

Not ’till now.

(BT-Driver is Widcomm 1.4.x but it should work with 1.3 too)

  1. Open the Advanced Bluetooth configuration.
  2. Client Applications Tab.
  3. Add COM Port
  4. OK to everything
  5. Double click the BT-Icon in the Tray
  6. “View devices in range”
  7. Double click your phone
  8. Right-click “Serial Port 2” and create a shortcut.
  9. go up two levels.
  10. right click the created shortcut, properties.
  11. Select the newly created port
  12. OK everything
  13. In the control panel open the Ericsson Phone Monitor
  14. In COM Ports, select the newly created port, chose “Reserve” and “Enable”
  15. OK

Before synchronizing, double click the newly created shortcut in your “bluetooth places”. The phone will not immediatly be detected, but as soon as you start XTNDConnect and hit “synchronize”, it will be.

What you did with this steps is creating two virtual com-ports for the phone that can be concurrently used. That way you can use XTNDConnect to synchronize with outlook and MobileAgent for the rest. Very nice.

Programmers Font

When writing code here and then, you usually use a monospaced font for better alignment of the characters. The default in Windows is Courier New which is quite readable, but its characters are a bit wide.

My favourite so far has been Lucida Console which comes with Windows XP and maybe Microsoft Office. The fonts characters are a bit less wide than those in Courier New. This is my default-font in Putty as it’s very readable (for a monospaced font) and doesn’t use as much space as Courier does.

Somewhere on the web, I came across ProFont which is a modified version of Monaco, the mac users have as default monospaced font. ProFont is optimized to be used by programmers, can be set to a very small size (lots of code visible without scrolling) and is very very readable.

On the page you’ll find a bitmap and a truetype version. The latter looks quite badly on Windows XP with ClearType and the former doesn’t work in Java-Applications. Unfortunatly jEdit is indeed written in Java, so I have to use the TT variant.

Then again, Delphi and Putty are not written in Java, so I want to use the bitmap version.

Unfortunatly, it’s not possible to install both fonts at the same time as the are both named the same, so the TT version always wins.

My solution: I’ve opened the bitmap-font with a hex editor and changed all ocurrences of ProFontWindows to something else which finally allowed me to install both fonts at the same time.

Get the hacked version here. Note that I’ve only hacked the fontname. All its copyright belong to the author of the page above.