sscanf and sprintf on mc9s12dj128b

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

sscanf and sprintf on mc9s12dj128b

1,670 Views
Bobby
Contributor I
Hello,

I want to extract some informations from a string.
This string has not always the same lengh, but all values are separated by a ",".
The string on wich I work is an NMEA GPS string for people who now their structure.

So what I want to do is a sscanf. The fonction work properly on a PC with visual studio 2005. But the same code don't want to work on my mc9s12. The compilator doesn(t return any error but no values has extracted.

I'm using sscanf like below :
nbValuesReturned = sscanf(dataReceived,"$GPRMC,%2d%2d%2d.00,%c,%2d%f,N,%2d%f,E,%*f,%f,%2d%2d%2d",time.hour,time.minute,time.seconde,validity.positionOk,latitudeDegree,position.latitude,longitudeDegree,position.longitude,position.course,time.day,time.month,time.year);

I know the line is very long but I've test on shorter strings but it is the same thing.

Is someone has an idea ? Maybe sscanf can't work on mc9s12 ?

I have the same problem with sprintf wich is the opposite of sscanf.

I'm sorry for my english. If someone has an idea it will be really usefull for me.

Thanks,

Bobby
Labels (1)
0 Kudos
Reply
2 Replies

547 Views
kwik
Contributor I
Bobby ; I wouldnt attack the problem this way.
The GPS might have a different output on a day to day basis.

Someone might change the GPS setup.
It depends of course how robust you need your code to be,and how
"serious" the application is. If its a serious commercial
application ,you shold go another route.

Then you should take the received string and pass it to a
function that splits the string in an array of strings.

The comma would need to be the separator.Luckily such a function
is testable in an XP environment....

In e.g CSharp (C#) this is called Split(.....) ,which returns an array
to you. Here Im afraid you must make the split() routine yourselves.

Unless you are lucky,and finds it on the Net.

Then ,you must check the beginning of each little string ,and check
what it begins with .If its an 'N' its the North ,if its an 'E' its
the East ,and so on.

Regards ,
kwik
0 Kudos
Reply

547 Views
CrasyCat
Specialist III

Hello

sscanf should work with HCS12 CPU.

Basically if you want to use sscanf or sprintf in your application:

  - Make sure to include stdio.h in each source file, where you are using one of these function
  - Make sure to define a big enough stack. (try to define at least 1.5 K of stack)

If this does not help please submit a service request through our web site. Make sure to attach a project
reproducing the issue to the request.

CrasyCat

0 Kudos
Reply