From: Enoch <ix...@ho...> - 2013-03-04 09:14:59
|
Hello Matthias & all: As I promised to generalize crc8.frt (#1) a question was raised how would the user configure it to its use, namely, select the generating polynomial byte and the needed bit order (#2). I answered the question through the following amforth-shell.py improvement which introduces a local appl_owns.py substitutions file. Without further ado here's the patch and its use for your perusal: Patch: http://pastebin.com/uDK7fk9N Example: $ cat appl_owns.py # amforth-shell.py application specific forth substitutions APPL_OWNS = { 'DEBUG': '1' } $ make shell ...snip... (AT90CAN128)> DEBUG . 1 ok Regards, Enoch. #1 Assuming that Matthias places it in ${AMFORTH}/lib/crc8.frt :-) #2 With no real constant-s to pay for in the user code. |
From: Matthias T. <mt...@we...> - 2013-03-04 18:39:27
|
Hi Enoch, > > As I promised to generalize crc8.frt (#1) a question was raised how would > the user configure it to its use, namely, select the generating > polynomial byte and the needed bit order (#2). > > I answered the question through the following amforth-shell.py > improvement which introduces a local appl_owns.py substitutions file. > > Without further ado here's the patch and its use for your perusal: > > Patch: http://pastebin.com/uDK7fk9N A few notes + sys.path.insert(0, ".") if os.environ.has_key("AMFORTH_LIB"): self._search_list = os.environ["AMFORTH_LIB"].split(":") - else: - self._search_list=["."] During my tests I found that change less useful. I run the shell not only from the appl directory but also from $HOME, so adding "." to the search path leads to a huge amount of files, the shell reads in upon start (on my system it took more than only a few seconds. And I have 8GB RAM, but my $HOME is bigger). So I reject this part of the patch. Sorry. For the other stuff "appl_own.py" I've not opinion yet. What exactly is the problem you want to solve? What I would like to have is something that could the following (forth code!) [undefined] foo #include foo [endif] for which the shell sends the content of foo unless foo is already defined. The control words are not sent to the controller as well. File oriented forth's have something like that, and I think the shell is capable of doing something similiar. Matthias |
From: Enoch <ix...@ho...> - 2013-03-04 19:15:51
|
Matthias Trute <mt...@we...> writes: > Hi Enoch, > >> >> As I promised to generalize crc8.frt (#1) a question was raised how would >> the user configure it to its use, namely, select the generating >> polynomial byte and the needed bit order (#2). >> >> I answered the question through the following amforth-shell.py >> improvement which introduces a local appl_owns.py substitutions file. >> >> Without further ado here's the patch and its use for your perusal: >> >> Patch: http://pastebin.com/uDK7fk9N > > A few notes > > + sys.path.insert(0, ".") > if os.environ.has_key("AMFORTH_LIB"): > self._search_list = os.environ["AMFORTH_LIB"].split(":") > - else: > - self._search_list=["."] > > During my tests I found that change less useful. I run the shell > not only from the appl directory but also from $HOME, so adding > "." to the search path leads to a huge amount of files, the > shell reads in upon start (on my system it took more than only > a few seconds. And I have 8GB RAM, but my $HOME is bigger). So > I reject this part of the patch. Sorry. Point taken, I'll amend. My project resides outside the amforth hierarchy, hence, I did not notice the hit. > For the other stuff "appl_own.py" I've not opinion yet. What > exactly is the problem you want to solve? What I would like to > have is something that could the following (forth code!) > > [undefined] foo > #include foo > [endif] That all came in context of crc8.frt. It needs two configurable constants as both the polynomial chosen and the reading order are application specific (in fact MSB first is considered the reverse order). ( $D5 constant CRC8PLY -1 constant CRC8MSB ) I said, how nice it would be if amforth-shell would do it for me just like it does with Atmel's register/bit defs. By the way, I surround the above constants with () which amforth-shell.py respects but amforth itself does not. That's just perfect! Regards, Enoch. > > for which the shell sends the content of foo unless foo is already > defined. The control words are not sent to the controller as well. > > File oriented forth's have something like that, and I think the > shell is capable of doing something similiar. > > Matthias > > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_d2d_feb |
From: Matthias T. <mt...@we...> - 2013-03-04 19:50:55
|
Enoch, > I said, how nice it would be if amforth-shell would do it for me just > like it does with Atmel's register/bit defs. That makes sense. But appl_own.py as the filenname..... There should be better ones. Or a more generic approach. I'm not a python expert, but many python directories contain a file named __init__.py to do something useful. > > By the way, I surround the above constants with () which amforth-shell.py > respects but amforth itself does not. That's just perfect! Uhm. Other would have call it a bug ;) Matthias |
From: Enoch <ix...@ho...> - 2013-03-04 20:07:43
|
Matthias Trute <mt...@we...> writes: > Enoch, > >> I said, how nice it would be if amforth-shell would do it for me just >> like it does with Atmel's register/bit defs. > > That makes sense. But appl_own.py as the filenname..... There should > be better ones. Or a more generic approach. I'm not a python expert, > but many python directories contain a file named __init__.py to do > something useful. Seems too "pythonic" for me :-) In fact, I would have preferred it to be appl_owns.frt with "$D5 constant CRC8PLY" lines, only that I am too lazy :-) Regards, Enoch. >> >> By the way, I surround the above constants with () which amforth-shell.py >> respects but amforth itself does not. That's just perfect! > > Uhm. Other would have call it a bug ;) > > Matthias > > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_d2d_feb |
From: Enoch <ix...@ho...> - 2013-03-05 05:37:45
|
Hello Matthias & all: > Matthias Trute <mt...@we...> writes: >> That makes sense. But appl_own.py as the filenname..... There should >> be better ones. Or a more generic approach. I'm not a python expert, >> but many python directories contain a file named __init__.py to do >> something useful. > > Seems too "pythonic" for me :-) > In fact, I would have preferred it to be appl_owns.frt with > "$D5 constant CRC8PLY" lines, only that I am too lazy :-) > Thanks for the encouragement. I hope that my new attempt to patch amforth-shell.py is better. Patch: http://pastebin.com/ENbdSkj5 Usage: Create a file in the application directory called appl_defs.frt: Yes, a forth file :-) \ example 0 constant false -1 constant true $d5 constant CRC8PLY -1 constant CRC8MSB Let's create the test.frt: \ #error-on-output no ( $d5 constant CRC8PLY -1 constant CRC8MSB ) CRC8PLY . CRC8MSB . $ make shell AMFORTH_LIB=.:/home/enoch/avr/amforth/trunk/lib python /home/enoch/avr/amforth/trunk/tools/amforth-shell.py -p /dev/ttyUSB2 |I=appl_defs: example |I=appl_defs: 4 loaded |I=Entering amforth interactive interpreter |I=getting MCU name.. |I=successfully loaded register definitions for at90can128 |I=getting filenames on the host |I= Reading . |I= Reading /home/enoch/avr/amforth/trunk/lib (AT90CAN128)> #include test.frt |D=#include test.frt |I=getting filenames on the host |I= Reading . |I= Reading /home/enoch/avr/amforth/trunk/lib |I=using test.frt from/home/enoch/private/project **** /home/enoch/private/project |I=getting MCU name.. |I=successfully loaded register definitions for at90can128 |F=/home/enoch/private/project/test.frt |D| 1|\ #error-on-output no |W| 2| |C| 3|( |C| 4|$d5 constant CRC8PLY |C| 5|-1 constant CRC8MSB |C| 6|) |W| 7| |S| 8|CRC8PLY . |O| 8|213 |S| 9|CRC8MSB . |O| 9|-1 |W| 10| * Regards, Enoch. |