Friday, July 9, 2010

Posting code

It seems really weird that blogger doesn't have facilities for posting code honoring linebreaks, whitespace and maybe even syntax highlighting. There are some workarounds where you paste code in some textfield and get html that you're supposed to paste into your blog. I think that sucks.

I edited my template and changed .post-body blockquote to read:

.post-body blockquote {
border:1px dashed #dddddd;
background-color:#eeeeee;
padding:10px;
font-size:9pt;
white-space: pre;
font-family: monospace;
}

Now you can paste your code even using the HTML editor using the quote-button. Of course, it still doesn't do syntax highlighting and neither does it work for HTML, but its a start.

gsmlib

I got a huawei e620 / vodafone K3520 umts usb stick to send and receive sms using linux.

Unfortunately, gsmlib-1.11_pre041028 seems to be unmaintained right now. Gentoo already carries patches to enable compilation with gcc3.4, 4.1 and 4.3, and Mr. Hofmann doesn't seem to reply to emails. At least reading his code turned out to be easy - thanks for that!

Anyway, when I tried

gsmsendsms -d /dev/ttyUSB0 -C +491710760000 +49160<...> Wheeeeeeeee


all I got was

gsmsendsms[ERROR]: expected parameter (at position 1 of string ',1,1,1')


I wondered for quite a while where the heck gsmsendsms thought I had passed such a parameter, but later found out that the string ",1,1,1" was actually a reply to an AT-command issued to the huawei stick.

To keep a longer story of recompiling, reading, replugging the stick, and looking up AT commands short, here's the patch - hopefully self-explanatory:

--- /tmp/gsm_me_ta.cc 2010-07-09 12:07:13.091842964 +0200
+++ /usr/src/gsmlib-1.11/gsmlib/gsm_me_ta.cc 2010-07-09 12:10:08.105440813 +0200
@@ -120,7 +120,22 @@

// find out whether we are supposed to send an acknowledgment
Parser p(_at->chat("+CSMS?", "+CSMS:"));
- _capabilities._sendAck = p.parseInt() >= 1;
+
+ try
+ {
+ _capabilities._sendAck = p.parseInt() >= 1;
+ }
+ catch (GsmException)
+ {
+ // Some huawei usb gsm/umts sticks reply to AT+CSMS? with "+CSMS: ,1,1,1"
+ // There probably should be a 0 or 1 before the first comma, indicating
+ // whether an incoming SMS should be acknowledged (by issuing +CNMA).
+ // This causes parseInt() -> checkEmptyParameter() to throw an exception
+ // I suppose that if the huaweis needed this, they would have taken care
+ // to set the first bit to 1.
+ // Confirmed so far only for E620 / Vodafone K3520
+ _capabilities._sendAck = false;
+ }

// set GSM default character set
try


gsmsmsd throws a "303 unsupported" error when used with "--direct" (enable direct routing of SMSs). I might have to look into that next.

I remeber typing those ATDTs back in the nineties and just love how they made it into the new milennium :)