![]() |
Forum Index : Microcontroller and PC projects : Maxiterm Terminal Program and function questions
Author | Message | ||||
frnno967 Senior Member ![]() Joined: 02/10/2020 Location: United StatesPosts: 104 |
Using an Adafruit Feather Huzzah ESP8266 module, I've been able to reliably connect to BBS systems with ASCII. And after updating to the 5.05.06 beta firmware, I've integrated Xmodem file transfers to the program. But an issue has come up that I don't know how to solve, and it might involve a feature request too. When calling the XMODEM S FILENAME, COMPORT or XMODEM R FILENAME, COMPORT commands for downloading or uploading to a BBS, XMODEM sometimes will return with an error, and thereby crash the program. So my question is how do I handle MMBasic exceptions from within a program? For example, when it crashes it tells me the error like "Error in line 399: Too many errors" or "Error in line 399: No response from remote," but is there a way to catch the exception without crashing so that I can return a sensible error message to the user and give them an opportunity to resolve the situation or continue with the session? The other part that is more of a feature request is that is there any way that XMODEM can present a progress indication of some kind when called from within a program? Other notes: Downloads seem to work okay without crashing, but I haven't yet compared the received files to be sure they're not corrupted in some way. The lack of progress indication isn't helpful, but at least the "BUSY" LED on the front of the CMM2 flashes. Uploading hasn't worked yet. I'm worried that it might be a flow control issue with the CMM2 overwhelming the Huzzah but don't know how to troubleshoot it aside from running a packet capture to diagnose it. Implementing a flow control routine might be tough since it's the firmware Xmodem routine handling the transfer and it's not aware of flow control. Once some software routines are implemented I'm sure that can be debugged easier. If Vegipete is reading this post, I tried to use your getfile code to select the file for uploading, but I don't really understand how it works and had trouble implementing it. If you would care to clean that up and fix it it would be greatly appreciated! Its in the upload subroutine. Another question, is SELECT CASE only supposed to work for strings? I couldn't get it to work for integer variables. Had to use a bunch of IF.. ELSEIF instead. Finally, any constructive criticism is welcome. I've a novice programmer so this has been a very fun project and has helped me learn more about programming. Enjoy the program: maxiterm.zip Jay Crutti: Ham Radio Operator, K5JCJ. Computer Enthusiast. Musician. Engineer. |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
SELECT works OK with integers OPTION EXPLICIT OPTION DEFAULT NONE DIM INTEGER choice DIM k$ DO DO k$ = INKEY$ LOOP UNTIL k$<>"" choice = VAL(k$) SELECT CASE choice CASE 1 PRINT "one" CASE 2 PRINT "two" CASE 3 TO 9 PRINT "big number" CASE ELSE PRINT "Try again" END SELECT LOOP If you want fancy things like progress and clean error handling for XMODEM, you will have to roll your own. using ON ERROR SKIP might work but I think a better way is to do the XMODEM in Basic so you have full control. If the buffer in the ESP is less than 132 bytes, you will also have to do handshaking. Jim VK7JH MMedit |
||||
frnno967 Senior Member ![]() Joined: 02/10/2020 Location: United StatesPosts: 104 |
Thank you for the code, I think I see what was wrong now. If you are familiar with how INKEY$ works can you check my code I use for Local Echo? I couldn't get it to work correctly as it seems to be adding a CRLF after each character typed, when I really just want it to parrot exactly what is typed. If you're in the terminal hit ALT-E to enable it. You don't need to have a modem connected to try it. Jay Crutti: Ham Radio Operator, K5JCJ. Computer Enthusiast. Musician. Engineer. |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
On line 177 print INKEY$ PRINT will always append the CRLF pair unless you end the text with a semicolon. I think you should be doing PRINT echostr$; Jim VK7JH MMedit |
||||
frnno967 Senior Member ![]() Joined: 02/10/2020 Location: United StatesPosts: 104 |
It seems to have no effect, and now no characters are printing to the screen. Characters are still being sent to the modem and it's responding, but nothing is being echoed. Jay Crutti: Ham Radio Operator, K5JCJ. Computer Enthusiast. Musician. Engineer. |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
Perhaps it should be print CHAR_OUT$; I haven't looked too deeply at your code so only guessing. Jim VK7JH MMedit |
||||
vegipete![]() Guru ![]() Joined: 29/01/2013 Location: CanadaPosts: 1132 |
I guess I was being too fast and loose with my variables. I tend not to use OPTION EXPLICIT, in fact I've never used it, so my on-the-fly variable usage would never work... Try this version (1.2b) I also simplified the example program and tossed extra and confusing stuff. Should be close to bare bones example. There are some minor changes to the variables, mostly the result is returned in (the first element of) an array. (That's for other features in the pipe.) There's also a few more internal usage global variables, and a some custom characters in a custom font. You can turf the MakeBox and FillBackground subs, they're not needed. Hopefully this works for you. Let me know if not. ========== I didn't look closely through your program but the only comment I might have is the lack of comments. You can remember what it all does now but in a month or two after you've been doing something else, you will rue the lack of comments. Guess how I know... ;-) You may need to rethink the character echo a bit. You are reading INKEY$ in a few different places, so each instance could have a different value (or none at all.) Try to read INKEY$ only once at, say, the top of the DO LOOP. Also, watch your IF / ENDIFs. I'm not sure if this is correct or legal: if CHAR_OUT$ = chr$(137) then download end if if CHAR_OUT$ = chr$(136) then upload end if Good on you for tackling an interesting and non-trivial programming project! I've always found that to be the best way to learn more and get better. Visit Vegipete's *Mite Library for cool programs. |
||||
frnno967 Senior Member ![]() Joined: 02/10/2020 Location: United StatesPosts: 104 |
So I tried this and discovered that while it would echo the characters correctly, it was also stripping any carriage returns that were coming out of the feed. So by adding IF CHAR_OUT$ = chr$(13) THEN print chr$(13) after the print CHAR_OUT$; I was able to recover the carriage returns and print them on the console.end if Is this a bug in mmbasic? I thought that the semicolon at the end just meant that it wouldn't add a CR of it's own at the end of the print, not that it would refuse to print any CR coming through the pipe. Edited 2020-10-29 03:38 by frnno967 Jay Crutti: Ham Radio Operator, K5JCJ. Computer Enthusiast. Musician. Engineer. |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
<CR> is a strange beast to tame. Some sources will have just <CR> some will have just <LF> and some will have both <CR><LF> You have to convert that to <CR><LF> PRINT"Fred"+CHR$(10); PRINT "Wilma"+CHR$(10)+CHR$(13); PRINT "Barney" VK7JH MMedit |
||||
frnno967 Senior Member ![]() Joined: 02/10/2020 Location: United StatesPosts: 104 |
Sure, but I'm not talking about data incoming from the modem. This is data that is being typed into the CMM2, then being read out from INKEY$, assigned to a string variable, then printed back to the VGA display. INKEY$ seems to be doing its job correctly, but when PRINT INKEY$; is displaying the data it is stripping the CR's from the stream in addition to not adding its own. Jay Crutti: Ham Radio Operator, K5JCJ. Computer Enthusiast. Musician. Engineer. |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
Try the three different OPTIONs for CRLF ' 'option crlf crlf 'option crlf cr option crlf lf do do k$ = inkey$ loop until k$ <>"" print k$; loop Jim VK7JH MMedit |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |