Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 04:45 29 Nov 2024 Privacy Policy
Jump to

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 : MM mono Serial Problems II

     Page 2 of 2    
Author Message
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2817
Posted: 11:43am 24 Mar 2014
Copy link to clipboard 
Print this post

Try something like this to begin with (complete with correct indenting!) :


Open "COM2:19200" As #1
Do
Do
By$=Input$(1,#1)
MSG$=MSG$+By$
Loop until By$=CHR$(13) OR By$=CHR$(10) 'Checks for CR or LF
Print MSG$ 'helps give a view as to what is happening
Print ASC(MSG$) ' if this line causes the value 10 to be printed then the LF is your issue
if By$=CHR$(10) Then Goto L2_Done 'if LF when here then no need to check MSG$ so jump over MSG$ checks

If MSG$="1" Then Print" Choice 1"
If MSG$="2" Then Print "Choice 2"
.
.
.

L2_Done:
MSG$=""
Loop



For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.o
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9308
Posted: 11:50am 24 Mar 2014
Copy link to clipboard 
Print this post

Ahhhh - WW - so we meet again!!!!!

Yes, I like the idea of <cr> OR <lf> - good idea, and deals with them both in one line.

I used PRINT MSG$,LEN(MSG$) cos "Non-viewable" characters will still be there, but won't be visable, and it helps during debugging, to know exactly how long the string is, and if it tallies with what length in total you THINK it should be.
Smoke makes things work. When the smoke gets out, it stops!
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2817
Posted: 12:05pm 24 Mar 2014
Copy link to clipboard 
Print this post

Nic,

Change line in my code listed above to what Grogster suggests i.e. change to Print MSG$,LEN(MSG$)

All helps to give even more clues (but we already know whats happening don't we!!)



For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.o
 
Nixie
Regular Member

Joined: 19/02/2013
Location: Australia
Posts: 66
Posted: 05:48pm 24 Mar 2014
Copy link to clipboard 
Print this post

Guys! It's ALIVE! It Works! Thankyou Thankyou Thankyou!

I hadn't read your msgs above till now, but early this morning I solved it by getting rid of the LF. My two examples are below. Very Happy!

Open "COM2:19200" As #1
Print "Ready to Rx..."
Do
Do
By$=Input$(1,#1)
If By$=Chr$(10) Then By$="" 'Get rid of a LineFeed (LF)!
If By$=Chr$(13) Then Exit
MSG$=MSG$+By$
Loop

If MSG$="1" Then Print" Choice 1":Msg$=""
If MSG$="2" Then Print" Choice 2":Msg$=""
Print "->"+Msg$
msg$=""
Loop

----------------------and the steam-driven version:

100 Open "COM2:19200" As #1
110 Cls: Print "Ready to Rx..."
120 If Loc(#1)=0 Then 120
130 By$=Input$(1,#1)
135 If By$=Chr$(10) Then 350
140 Msg$=Msg$+By$

150 If Msg$="1"+Chr$(13) Then 400
155 If Msg$="2"+Chr$(13) Then 500

200 If By$=Chr$(13) Then Print "Rx: ";Msg$: Msg$=""
350 GoTo 120
' ----------------------------
400 Print "Menu selection 1"
405 Msg$=""
410 GoTo 200

500 Print "Menu Selection 2"
505 Msg$=""
510 GoTo 200


Now I have to streamline it all with your suggestions. GREAT! THANKS!

Grogster - no I don't use Jim's MMEDIT, will look at that

WHiteWizard - generally... Winter gets to no more than -2 deg C, no snow as BobD says, but still gets very white with frosts! What makes it worse, living on the grassy plains, is the constant wind (Chill factor!). I live in Vite Vite North, nearest 'corner store' is 30kms away...hmmm if Id known "Vite Vite" (pronounced Vyte as in byte) was Aboriginal for 'Windy! Windy! I'd have thought twice about moving to my darling's farm

Must see if there is a text or instructions online somewhere for structured coding.
(We use a satellite link (slow) for the internet)

Hooroo, Nic.


 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9308
Posted: 06:33pm 24 Mar 2014
Copy link to clipboard 
Print this post

No disrespect to the built-in editor(I am forever saying that), but once you try MMEdit, you will like very much.

I've kinda always preferred a PC application for developing the code, then just downloading it to the device for testing.

However, the internal MM editor is a great way to get an ENTIRE home-computer like system, all in the one package, with no other software required to get it up and running and writing your programs.

Very glad you got things working - let the experimentation begin!
Smoke makes things work. When the smoke gets out, it stops!
 
     Page 2 of 2    
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024