SlickEdit autogenerated Makefile configuration

February 3, 2010

SlickEdit autogenerated Makefile generate the following by default.

# SlickEdit generated file.  Do not edit this file except in designated areas.

# Make command to use for dependencies
MAKE=make
RM=rm
MKDIR=mkdir

# -----Begin user-editable area-----

# -----End user-editable area-----

# If no configuration is specified, "Debug" will be used
ifndef CFG
CFG=Debug
endif
.....

But what if you want to use another make application?
you need to do it in the Makefile itself:

...
# -----Begin user-editable area-----
MAKE=my-make
# -----End user-editable area-----
...


Simple UTF-8 C Decoder

December 23, 2008

This is a simple C or C++ code for UTF-8 decoder

// given that this is first byte of the character,
// how many bytes is the character occupy?
int NumberOfUTF8Chars(unsigned char ch)
{
if (ch < 0x80u) return 1;
else if (ch < 0xE0u) return 2;
else if (ch < 0xF0u) return 3;
else if (ch < 0xF8u) return 4;
else if (ch < 0xFCu) return 5;
else return 6;
}

// given that this is first byte of the character,
// what is the code value of that character?
unsigned int ValueOfUTF8Code(const char* ch)
{
unsigned int Value;
int Size = NumberOfUTF8Chars( *ch );
switch( Size )
{
case 6:
Value  = ch[0] & 0x01;
break;
case 5:
Value  = ch[0] & 0x03;
break;
case 4:
Value  = ch[0] & 0x07;
break;
case 3:
Value  = ch[0] & 0x0F;
break;
case 2:
Value  = ch[0] & 0x1F;
break;
case 1:
Value = ch[0];
}

for ( int i= 1; i < Size; i++ )
{
Value = Value << 6 | ch[i] & 0x3F;
}
return Value;
}

This code was never actually tested. Use it on your own risk.


LM058 communication problem

December 5, 2008

It should not escalated to this level and since it does it a bad evidence on the ‘LM Technologies’ brand.

I am working on a system the include communication from a smartphone to a controller.
The controller support RS232, the smartphone support Bluetooth and to bridge this gap I purchased a ‘Bluetooth Serial adaptor’ from ‘LM Technologies’.

The connection works well until the device sends a string longer than 20-40 characters. Then the LM058 freezes and never recovers. (power cycle require)

I tried all known configurations, I sent question to LM support (there website support is terrible), I posted a question in related forums (and in an unrelated forums :) .

At this stage it become apparent that either my device is faulty or just badly designed.

A week after my initial question to LM support I got response that suggested disabling the ‘escape character check’ using the AT command ‘ATX0‘. That indeed solve the problem.

BUT!!!
Why is this feature not documented in the LM058 user manual?? or any other related LM058 documents!!??

In the purpose of this blog I am adding a link to another adaptor manual that actually describe this feature. It seems that LM updated the LM058 adaptor functionality but not the manuals.

here it is: a little piece of information that was not part of the ‘world accumulated knowledge base’ (Internet) and now it is.
In the future I’ll try to be more informative and ‘to the point’ and less ‘blah blah’.


RIM JDE debug messages

November 25, 2008

Maybe it my fault that I didn’t read the whole of RIM’s documentation or maybe it just not there.

Anyway I was looking for a while for how to print debug messages in the JDE’s debug window and now I found it.
Simply use the system output stream:
System.out.println( "message " + number );


Odds conversion functions

November 4, 2008

Odds conversion is something you will hardly ever need. For most it would be sufficient to use a conversion tables.

But if you actually need to convert odds as part of a script here is how to do so:

There are three types of odds format:

  • Fractional: 9/5 for every 5 dollars you invest you get 9 if you win and the original 5 stake.
  • Decimal: 2.8 for every dollar you invest you get 2.8 dollars, that include the original stake.
  • American: American odds are divided to two parts positives and negatives.
    Positive: 180 for every $100 you invest you win $180 and get your $100 stake back.
    Negative: -180 to win $100 you need to invest $180, so if you invest $180 and win you get $100 and the $180 stake back.

Conversion between odds is rather simple.

Given the fractional odds numerator/denominator ( for short: num/den)
The decimal odds are computed as decOdds = ((num+den)/den)
The American odds are computed as follow
if (num/den > 1 )
    usOdds = ((num/den)*100)
else
    usOdds = ((den/num)*(-100))


RIM development environment serial port

October 16, 2008

I am developing a handheld application for my company. and it on a blackberry device. basically it’s a device programmer interfacing through a serial port. since blackberrys do not have serial port I’ll be using a Bluetooth to serial port converter, but for development I can use the BB serial port emulation through the PC port.

At first I use the class connector interface to open a serial port, as they use in their samples. but I couldn’t get it to accept messages coming over the port, I spent hours on that, tweaking the port and the code, nothing. The DataInputStream.available() always return zero, although I know it got a response. Eventually I found a different class, oddly enough named Class SerialPort that worked perfectly well. RIM did advised not to use it, but I am not going to use it for the final product anyway.


First steps with blogging

October 16, 2008

First part of writing a blog is opening an account. That was way too complicated: at first I wanted to open one in some technology site so others can find this information, after a long search I found toolbox but it seems that they only want good writers and they may not accept me as one. Well, I’m not gona be tested on my writing skills, that not my strength anyway. I search more, but haven’t found anything. I could open it in blogger or any of the massive blogging sites but I wanted a technology title, Engineers don’t look for solutions in Blogger…

Eventually I decided to open a blog in my own site, simple and straight forward. My hosting provider have wordpress ready to install, click clack and it’s running.

Now I had to add a bit of personal touch, so I downloaded a theme that suits me, tweaked it a bit and here you go.


My First Post

October 14, 2008

Welcome!

My name is Raz and I am a software engineer for 10 years now. As an engineer I am having challenges on daily basis, most are simple, easy and resolved by employing my knowledge and experience, Some are more difficult and require investigation, usually googling the problem and find the solution in over the web, and the last are challenges that it seems I’m the first to encounter or, to be more modest, no one ever post the solution on the web.

In general, I believe that sharing the knowledge on the web is important and so I decided to describe the third type challenges and solutions in my own blog, for others to enjoy.

This blog is not about me, it not going to be personal or interesting, just a list of facts and experiences that others can find and use in there challenges.


Follow

Get every new post delivered to your Inbox.