Hello, I'm looking for an open source SPCI parser to put in a microcontroller project (ATMEL AVR) I'd like to communicate with this device using a USB com (using a FTDI FT232) I see on http://compilers.iecc.com/comparch/article/00-07-096 http://coding.derkeiler.com/Archive/General/comp.arch.embedded/2007-12/msg00829.html that some other people wonder this... (without having any answer) Maybe you have a solution... Is there an open source implementation of a SPCI parser ? (at least a "free" implementation) I know the commercial JPA-SCPI Parser... but my device is not commercial (educational purpose) so I won't pay so much for this ! Maybe someone has ever made some lex/yacc script to do this... (because I don't like reinventing the wheel) Kind regards Sebastien Celles
SPCI Parser
Started by ●April 18, 2009
Reply by ●April 20, 20092009-04-20
On Apr 18, 3:50=A0pm, "no...@nowhere.undef" <s.cel...@gmail.com> wrote:> Hello, > > I'm looking for an open source SPCI parser to put in a microcontroller > project (ATMEL AVR) > I'd like to communicate with this device using a USB com (using a FTDI > FT232) > I see onhttp://compilers.iecc.com/comparch/article/00-07-096http://coding=.derkeiler.com/Archive/General/comp.arch.embedded/2007-1...> that some other people wonder this... (without having any answer) > Maybe you have a solution... > Is there an open source implementation of a SPCI parser ? (at least a > "free" implementation) > I know the commercial JPA-SCPI Parser... but my device is not > commercial > (educational purpose) so I won't pay so much for this ! > Maybe someone has ever made some lex/yacc script to do this... > (because I don't > like reinventing the wheel) > > Kind regards > > Sebastien CellesSebastien I have done all of this with Lex/Yacc for a test&measurement product on a 68332 years ago. If this is not a commercial product, why would you want to take on the fairly painful process of getting Lex/Yacc going on an AVR? Why use such a PITA protocol (SCPI)? Will you need to support *RST, *IDN and their ilk from IEEE488? Do you need to support semicolons? Each of these brings another level of pain to the design process. A large part of the difficulty was getting yyparse.c and yylex.c to behave for the linker and in the memory of the 86332 and not think it is in a PC of any sort since I started with MKS. Are you using a BIG AVR? Do you know of a Lex/Yacc implementation that is already ported to a microcontroller? Once all of these questions are answered it is not so bad building up scan.l and cmds.y to be a SCPI parser Chris
Reply by ●April 21, 20092009-04-21
Thanks for discouraging me ;-) Let's say it won't be a SPCI parser... but just a parser for 3 commands : *IDN? MEAS? get a value SET value how will you do this (with or without lex/yacc) ? and why ? for now I have read this http://ds9a.nl/lex-yacc/cvs/lex-yacc-howto.html you don't think that a C source code generated on a PC using Lex/Yacc couldn't compile and fit in an ATmega 16 ?
Reply by ●April 21, 20092009-04-21
scls19fr wrote:> Thanks for discouraging me ;-) > > Let's say it won't be a SPCI parser... but just a parser for 3 > commands : > > *IDN? > MEAS? get a value > SET value > > how will you do this (with or without lex/yacc) ? and why ?This looks like a really small subset of SPCI. If you can't implement this on your own in some 20 lines of C in 10 minutes, you should try gardening instead of microcontroller programming :-)> for now I have read this > http://ds9a.nl/lex-yacc/cvs/lex-yacc-howto.html > you don't think that a C source code generated on a PC using > Lex/Yacc couldn't compile and fit in an ATmega 16 ?I don't see why there should be a problem. I have used lex and yacc on PC (Windows and Linux), only so far, but the output should be standard C, so every C compiler should be able to compile it. And if you don't try to implement the C++ lexer and grammar file, it should fit on microcontrollers. Maybe there could be problem with available library functions, but should be easy to implement it, e.g. if strlen or something is missing. -- Frank Buss, fb@frank-buss.de http://www.frank-buss.de, http://www.it4-systems.de
Reply by ●April 22, 20092009-04-22
On Tue, 21 Apr 2009 23:15:35 +0200, Frank Buss wrote:>> for now I have read this >> http://ds9a.nl/lex-yacc/cvs/lex-yacc-howto.html >> you don't think that a C source code generated on a PC using >> Lex/Yacc couldn't compile and fit in an ATmega 16 ? > > I don't see why there should be a problem. I have used lex and yacc on PC > (Windows and Linux), only so far, but the output should be standard C, so > every C compiler should be able to compile it. And if you don't try to > implement the C++ lexer and grammar file, it should fit on > microcontrollers. Maybe there could be problem with available library > functions, but should be easy to implement it, e.g. if strlen or something > is missing.Size could be an issue for a microcontroller (the ATmega16 has 16K of flash). Machine-generated code tends to have a fair amount of boilerplate. Also, even with all of the table compression options, a state table can be inefficient for some grammars.
Reply by ●April 22, 20092009-04-22
Thanks guys for your replies. To Frank... I like gardening too... ;-) but what we are talking is parsing an expression... it's, in my mind, quite different from programming a microcontroller since it's not just putting value in some registers... I have made a C source code (without Lex/Yacc) that implements the first two commands (with the hassle of upper case / lower case abbreviated commands) see http://svn.berlios.de/viewcvs/openphysic/c/projets/scpi or svn checkout svn://svn.berlios.de/openphysic/c/projets/scpi but I still wonder how I could do the third command !!!! I you have any idea it will be very helpfull I'd prefer doing in self made C source code than in Lex/Yacc because the generated code can but too long for this kind of little microcontroller On an other hand I 've read this lex/yacc tutorial http://ds9a.nl/lex-yacc/cvs/lex-yacc-howto.html I have modified it to understand this commands heat on Heater on! heat off Heater off! set temperature 22 New temperature set to 22! get temperature Temperature is 22 (temperature is integer) Source code is avalaible at http://svn.berlios.de/viewcvs/openphysic/compilation/2_yacc/thermostat2 or svn checkout svn://svn.berlios.de/openphysic/compilation/2_yacc/thermostat2
Reply by ●April 22, 20092009-04-22
On Sat, 18 Apr 2009 12:50:59 -0700 (PDT), "noone@nowhere.undef" <s.celles@gmail.com> wrote:>Hello, > >I'm looking for an open source SPCI parser to put in a microcontroller >project (ATMEL AVR) >I'd like to communicate with this device using a USB com (using a FTDI >FT232) >I see on >http://compilers.iecc.com/comparch/article/00-07-096 >http://coding.derkeiler.com/Archive/General/comp.arch.embedded/2007-12/msg00829.html >that some other people wonder this... (without having any answer) >Maybe you have a solution... >Is there an open source implementation of a SPCI parser ? (at least a >"free" implementation) >I know the commercial JPA-SCPI Parser... but my device is not >commercial >(educational purpose) so I won't pay so much for this ! >Maybe someone has ever made some lex/yacc script to do this... >(because I don't >like reinventing the wheel) > >Kind regards > >Sebastien CellesHi, If you can get hold of a copy of Anagram, I believe this would be ideal to generate suitable code. Look at http://www.parsifalsoft.com/ Unfortunately the author is deceased and the software seems to be unobtanium. Another case of why proprietary is not the best. If this was an open source project, it would still have been available. I have not seen any other tool that can generate parsers which are suitable for use on small MCUs. Regards Anton Erasmus
Reply by ●April 22, 20092009-04-22
Thanks Anton So in your mind, I shouldn't make the parser myself and I should use a lexer/parser tool to generate C sourse I didn't know the parser generator you provide me... I just know lex/ yacc and flex/bison it seems to be quite similar... so if I decide to use such a tool using GNU tools (or standard unix tools) is probably a better idea...
Reply by ●April 23, 20092009-04-23
scls19fr wrote:> To Frank... I like gardening too... ;-)I don't like it, but sometimes I try to do some artwork :-) http://www.shapeways.com/forum/index.php?t=msg&th=842> I have made a C source code (without Lex/Yacc) that implements the > first two commands > (with the hassle of upper case / lower case abbreviated commands) > see http://svn.berlios.de/viewcvs/openphysic/c/projets/scpi > or > svn checkout svn://svn.berlios.de/openphysic/c/projets/scpiI hope you don't want to use this code in your microcontroller, because the scpi.c has at least one memory leak. And the abbreviations algorithm is wrong, e.g. "MicrocontrollErAS?" would be recognized as "MEASure?".> but I still wonder how I could do the third command !!!! > I you have any idea it will be very helpfull > I'd prefer doing in self made C source code than in Lex/Yacc > because the generated code can but too long for this kind of little > microcontrollerHow does the SET command look like? The SPCI standard doesn't say anything about the data you can use for it. SPCI looks very over designed anyway. But if you want to parse more complex structures, like key/value pairs for the set command, semicolon delimited commands or e.g. the intersting CALCulate commands, I would use a recursive descent parser. if implementing it by hand, e.g. like I've demonstrated in this code: http://groups.google.de/group/de.sci.electronics/msg/c1467276cd3776c9> On an other hand I 've read this lex/yacc tutorial > http://ds9a.nl/lex-yacc/cvs/lex-yacc-howto.html > I have modified it to understand this commands > heat on > Heater on! > heat off > Heater off! > set temperature 22 > New temperature set to 22! > get temperature > Temperature is 22 > (temperature is integer) > Source code is avalaible at > http://svn.berlios.de/viewcvs/openphysic/compilation/2_yacc/thermostat2 > or > svn checkout svn://svn.berlios.de/openphysic/compilation/2_yacc/thermostat2Are you sure this is allowed in SPCI? I've found the set command in the system subsystem, but not a get command, but I don't know which command of MEASURE, FETCH, INITIATE etc. you have to use to get some sensor value, if you want to comply to SPCI. -- Frank Buss, fb@frank-buss.de http://www.frank-buss.de, http://www.it4-systems.de
Reply by ●April 24, 20092009-04-24
On 23 avr, 07:51, Frank Buss <f...@frank-buss.de> wrote:> scls19fr wrote: > > To Frank... I like gardening too... ;-) > > I don't like it, but sometimes I try to do some artwork :-) > http://www.shapeways.com/forum/index.php?t=msg&th=842Wow ! maybe Pixar should hire you ;-) And I should work on microcontrollers in fields such as defence (what about a missile laucher) ;-)> I hope you don't want to use this code in your microcontroller, because the > scpi.c has at least one memory leak. And the abbreviations algorithm is > wrong, e.g. "MicrocontrollErAS?" would be recognized as "MEASure?".What should MicrocontrollErAS? stands for ? It would be nice to say where is the memory leak and how I could find it (valgrind ?)> http://groups.google.de/group/de.sci.electronics/msg/c1467276cd3776c9I will have a look at your code Kind regards