Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : MM170 and MM plus differences.
Author | Message | ||||
Bizzie Senior Member Joined: 06/07/2014 Location: AustraliaPosts: 185 |
I have a strange thing happening! You may have seen my comment in the post ""Idle curiosity about internal stack space" " Re the behaviour of a MM170 and an MMplus board (GCMICROBOARD2B). Here is another problem I have turned up. The 170MM first ? MM.DEVICE$ Micromite MkII > ? MM.VER 5.0408 > new > xmodem r Saved 596 bytes > list Sub RadioSend(d As INTEGER,s As INTEGER,msg As STRING) Local STRING qq$ Local INTEGER chk,m qq$=ZPad$(d)+ZPad$(s)+msg For m=1 To Len(qq$):chk=chk+Asc(Mid$(qq$,m,1)):Next qq$=Chr$(STX)+Hex$(chk,4)+Chr$(GS)+ENCRYPT$(qq$)+Chr$(ETX) Print#io, String$(DoPreamble,Chr$(&HFE))+qq$; Pause Len(qq$)' wait for the packet to go End Sub Function ZPad$(x As INTEGER) ZPad$ = Right$("000" + Str$(x), 3) End Function Function ENCRYPT$(A$) Local N,P As INTEGER Local B$ P=1 For N=1 To Len(A$) B$=B$+Hex$(Asc(Mid$(A$,N,1),2) Xor Asc(Mid$(KEY$,P,1)),2) P=P+1:If P>Len(KEY$) Then P=1 Next ENCRYPT$=B$ End Function > radiosend 1,0,"test" 02E130303130303074657374 > And the PLUS ? MM.DEVICE$ Micromite Plus > ? MM.VER 5.0408 > new > xmodem r Saved 596 bytes > list Sub RadioSend(d As INTEGER,s As INTEGER,msg As STRING) Local STRING qq$ Local INTEGER chk,m qq$=ZPad$(d)+ZPad$(s)+msg For m=1 To Len(qq$):chk=chk+Asc(Mid$(qq$,m,1)):Next qq$=Chr$(STX)+Hex$(chk,4)+Chr$(GS)+ENCRYPT$(qq$)+Chr$(ETX) Print#io, String$(DoPreamble,Chr$(&HFE))+qq$; Pause Len(qq$)' wait for the packet to go End Sub Function ZPad$(x As INTEGER) ZPad$ = Right$("000" + Str$(x), 3) End Function Function ENCRYPT$(A$) Local N,P As INTEGER Local B$ P=1 For N=1 To Len(A$) B$=B$+Hex$(Asc(Mid$(A$,N,1),2) Xor Asc(Mid$(KEY$,P,1)),2) P=P+1:If P>Len(KEY$) Then P=1 Next ENCRYPT$=B$ End Function > radiosend 1,0,"test" 01C074657374 > You may note the variable DoPreamble is not defined "that's OK" as it is zero. Yes just tested it made no difference. Now to the real problem! Note the output is different WHY? This code was written by CaptainBoing and can be found on the fruits of the shed. Anyone got any comments/suggestion before I reload MMbasic on the PLUS? Rob White |
||||
led-bloon Senior Member Joined: 21/12/2014 Location: AustraliaPosts: 202 |
In Function ENCRYPT$(A$) Try, initialising B$ before use: Local B$="" Worth a try! led Miss you George |
||||
Bizzie Senior Member Joined: 06/07/2014 Location: AustraliaPosts: 185 |
Sorry as usual all my fault!! I had left the library in place, there was a duplicate ZPad$ function in the library but with different output! I believe this was being called. Deleting the library gave me identical results. Not sure why the duplicates did not cause an error. A lesson to anyone trying to use the HumanTime and Unixtime routines and the networking routines. Spent quite some time chasing this - Oh the fun of programming!! Rob White |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3165 |
I'm sorry but you will need to be much more specific. We could embark on a journey of discovery and spend a deal of time reverse engineering your code to guess what you want to do but a something more succinct would be much better (and will get you a good response). Can you distil the issue down to just a few lines of code with a proper explanation? EDIT: You beat me to it. But the message remains the same... reduce the issue to a few lines of code. No one wants to spend time digging through obscure code to provide help. Geoff Edited 2020-07-08 15:49 by Geoffg Geoff Graham - http://geoffg.net |
||||
Bizzie Senior Member Joined: 06/07/2014 Location: AustraliaPosts: 185 |
What I am trying to say there is an inconsistency between the reporting of errors within a program to one the command line. When the library contains a function of the SAME NAME If I load a function into the library eg:- These examples are with the MMplus as above. > library list Function ZPad$(x As INTEGER) Print "this is ZPad" End Function > And I then type this as a program into memory :- > list Print zpad$ Function zpad$() zpad$ = "This is zPad$ main memory" End Function and run the code by typing RUN I get > run [LIBRARY] Function ZPad$(x As INTEGER) Error: Duplicate name > As I would hope, may take some time to work this error out as NO mention duplicate is in the library. BUT if I type the following at the command prompt I get something different:- > print zpad$() this is ZPad > NO mention of an error. Now I use the command line regularly to test routines, in this case I was not aware of an error just unexpected results. Note also if you look at my original post the results are being sent to the console from a print#io,.... command, I was not aware that if #io = 0 output goes to the console again no error reported. I will use this feature a lot more now I have found it. Rob White |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3165 |
OK, I get it. Thanks. This basically comes down to MMBasic reporting an error in an intelligent way. I have struggled with this for some time. The bottom line is that there is no way for an interpreter that fits into a micro controller to provide a sensible error message for all the many ways that someone can mangle a command line. At this time MMBasic catches the more obvious mistakes but some times it just trips off into somewhere obscure. I'm afraid that this is just a case where the programmer will have to figure out the problem for themselves - as you have done. Geoff Geoff Graham - http://geoffg.net |
||||
Paul_L Guru Joined: 03/03/2016 Location: United StatesPosts: 769 |
Hey Geoff, If you've stuffed the available microprocessor memory with sensible, verbose message text maybe it's time to drop back to less convenient message numbers and an available external text file linking the error number to some verbose text. We ran into this at Pan Am with an early Sperry / Hawker Sideley test computer for the 707 autopilot. It ran on a PDP11 with limited core memory. The printed error list had 117,400 error messages. It numbered them based on ATA maintenance manual chapter definitions -- Chapter 23 = communications, 27 = fuel systems, 34 = navigation plus sub chapter numbers for each system. The resultant error code might look like 34.13.402 or something. That would break to 34=navigation, 13=VOR #1, 402=specific condition. Us polacks have a pronounced propensity to perambulate through a polysyllabic vocabulary thus creating confusion with a profusion of pedantic polymorphism .... but sometimes it's better to just say 57 54 46. Paul in NY |
||||
lizby Guru Joined: 17/05/2016 Location: United StatesPosts: 3010 |
Superfluity, Paul, 8 characters to express 3. PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
Paul_L Guru Joined: 03/03/2016 Location: United StatesPosts: 769 |
Now you've got it. That's polymorphism! Paul in NY |
||||
Tinine Guru Joined: 30/03/2016 Location: United KingdomPosts: 1646 |
If you've stuffed the available microprocessor memory with sensible, verbose message text maybe it's time to drop back to less convenient message numbers and an available external text file linking the error number to some verbose text. We ran into this at Pan Am with an early Sperry / Hawker Sideley test computer for the 707 autopilot. It ran on a PDP11 with limited core memory. The printed error list had 117,400 error messages. It numbered them based on ATA maintenance manual chapter definitions -- Chapter 23 = communications, 27 = fuel systems, 34 = navigation plus sub chapter numbers for each system. The resultant error code might look like 34.13.402 or something. That would break to 34=navigation, 13=VOR #1, 402=specific condition. Us polacks have a pronounced propensity to perambulate through a polysyllabic vocabulary thus creating confusion with a profusion of pedantic polymorphism .... but sometimes it's better to just say 57 54 46. Paul in NY Sounds reasonable to me. I don't clutter my MM code with strings but instead send binary numeric codes to my Android HMI via Bluetooth. |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8567 |
Tips for how to completely put off a newcomer: 1: Have it print "error: 472" when they make the simplest code mistake Edited 2020-07-11 17:36 by matherp |
||||
Tinine Guru Joined: 30/03/2016 Location: United KingdomPosts: 1646 |
1: Have it print "error: 472" when they make the simplest code mistake I don't believe that being put off the MM is even possible |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9051 |
When I started programming in my teens, it was on an Atari 800XL, running at an amazing 1.8MHz with 64KB of RAM. ATBASIC(Atari BASIC) had error codes like that. If it ran into a problem in the program, it would stop with something like "ERROR- 170", so it was a very common way to report errors in days gone past. But, yeah, I do remember having to have the error list printed out beside the computer so that whenever I got one of those, I had to look up the list for the definition of the error. Readable error messages are vastly better, but if space was a problem for new firmwares in the MM2, I would not care if the error reporting went back to numbers. But matherp has a point - many people these days won't like error numbers and having to look up a list. Not that it is hard to do, but people just won't like it. Smoke makes things work. When the smoke gets out, it stops! |
||||
robert.rozee Guru Joined: 31/12/2012 Location: New ZealandPosts: 2285 |
would it be worthwhile and/or practical to think about having TWO levels of error checking. the first would be when you saved a program and it was tokenized, the second would be when running the program. for example: DO LOOP would produce an error when the program was saved/tokenized. it would then NOT be necessary for the interpreter to look out for this syntax error. an obvious problem would be how to solve the issue of a program that contains deliberate errors in portions of code that are not intended to ever run. for example: GoTo start here are some notes that are not marked as comments, that will nonetheless never be seen by the interpreter. start: [...] but there may be workarounds. the question is: would such a scheme simplify the interpreter and/or make it faster? cheers, rob :-) |
||||
Tinine Guru Joined: 30/03/2016 Location: United KingdomPosts: 1646 |
And then there is the "Lite" version which could be a candidate because that would be more for the experienced user who is running short on available program space. |
||||
Print this page |