barnybug/wmr100 — pull request #8 by davepeake (2012-12-29 06:30:08+00:00)
Title: Swapped asprintf to sprintf due to a wierd bug in asprintf

For my installation of wmr100 on my raspberry pi the asprintf functions were printing garbage even though the syntax was correct.

ie:

```
asprintf(&msg, "type=TEMP,sensor=%d,smile=%d,trend=%s,temp=%.1f,humidity=%d,dewpoint=%.1f", sensor, smiley, trendTxt, temp, humidity, dewpoint);
```

would print mostly zeros but humidity would be a seven digit integer while

```
sprintf(msg, "type=TEMP,sensor=%d,smile=%d,trend=%s,temp=%.1f,humidity=%d,dewpoint=%.1f", sensor, smiley, trendTxt, temp, humidity, dewpoint);
```
would print it correctly.

Explicitly:

```
asprintf(&msg, "type=TEMP,sensor=%d,smile=%d,trend=%s,temp=%.1f,humidity=%d,dewpoint=%.1f", sensor, smiley, trendTxt, temp, humidity, dewpoint);
printf("%s\n",msg);
free(msg); msg = malloc(200);
sprintf(msg, "type=TEMP,sensor=%d,smile=%d,trend=%s,temp=%.1f,humidity=%d,dewpoint=%.1f", sensor, smiley, trendTxt, temp, humidity, dewpoint);
printf("%s\n",msg);
```
prints

```
Receive packet len 12: 30 42 30 e0 00 36 00 30 00 30 18 02
type=TEMP,sensor=0,smile=0,trend=,temp=6.4,humidity=1076213216,dewpoint=0.0
type=TEMP,sensor=0,smile=0,trend=,temp=22.4,humidity=54,dewpoint=0.0
```

I suspect it may have something to do with the memory allocation which makes little to no sense with asprintf?