We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, i am new on arm. does any one have a string parser example for lpc2138 cpu.
Thanks Orko
In what way would that be specific to the lpc2138? Or to any particular target or host environment?
Surely it's just standard string processing??
Hi,
i am sure it is standart processing. but i could't find some functions like strtok on keil so i think may be there is an another way to split string.
i specify processor for architecture.
Thanks
"i could't find some functions like strtok on keil"
Maybe you should use an 8051 instead, then:
http://www.keil.com/support/man/docs/c51/c51_strtok.htm
;-)
Try writing your own function, either from scratch or wrap your code around strpbrk. It would be a good exercise in coding 101 and just for the heck of it, test it on VisualC
"Try writing your own function ... It would be a good exercise in coding 101 "
Good idea!
As there is nothing specific to the lpc2138 or the ARM architecture, you could take any of the open-source offerings as your starting point...
www.google.com/.../advanced_code_search
Quick note: It doesn't matter what processor you use. You should really think twice before using strtok(), since it is non-reentrant and changes the input string.
Look at strchr(), strspn() or similar.
The current Keil ARM compiler & library does support strtok and I beleive it has been supported for some time.
"The current Keil ARM compiler & library does support strtok and I beleive it has been supported for some time."
As they are part of the standard 'C' library, it would be extremely surprising if they were not supported!!
As I noted earlier, even the C51 compiler has them!
When the OP said he couldn't find them, I very much suspect that he just didn't look (hard enough).
But, as Keil still haven't got the Realview manuals online yet, I can't check...
If your favorite string function does happen not to be supported, or happens not to be ANSI (that is, GNU or Unix libraries), you might look for source from the FreeBSD library:
www.freebsd.org/.../
"... you might look for source from the FreeBSD library"
And while you're there you might consider strsep() as a replacement for strtok() since it addresses strtok's problems alluded to by Per Westermark.