Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 01:40 28 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 : PicoMite V5.07.08 betas

     Page 8 of 11    
Author Message
carlschneider
Senior Member

Joined: 04/08/2023
Location: South Africa
Posts: 158
Posted: 10:53pm 31 Aug 2023
Copy link to clipboard 
Print this post

Hi Peter

Here is a short piece of code to demonstrate the above POSTs behaviour :)


If MM.Info(ip address) = "0.0.0.0" Then
Print "Failure to connect to the Internet - Restart"
CPU restart
EndIf

Print MM.Info(ip address)

On ERROR SKIP 5
WEB NTP -6 'Saskatoon
If MM.Errno Then WEB NTP -6
If MM.Errno Then WEB NTP -6
If MM.Errno Then Print "Failure to connect to the NTP Server" : CPU RESTART

WEB tcp interrupt ServiceWebInterrupt

Do
'^C out of this
Loop

Sub ServiceWebInterrupt
Local buff%(4096/8), a%
 For a%=1 To MM.Info(MAX CONNECTIONS)
   If Not MM.Info(TCP Request a%) Then Continue For
   WEB TCP READ a%, buff%()
   Print "a%=>";a%;
   Print "buf%() below"
   LongString Print buff%()
   WEB TRANSMIT PAGE a%, "settshort.html"
 Next a%
End Sub


Console output with Wireshark packets interleaved
No. Time Source Destination Protocol Length Info
1915 227.846694 172.16.1.68 172.16.1.75 HTTP 428 GET /settshort.html HTTP/1.1
1920 228.145220 172.16.1.75 172.16.1.68 HTTP 817 HTTP/1.1 200 OK  (text/html)
a%=> 1buf%() below <========== a%=1 here
GET /settshort.html HTTP/1.1
Host: 172.16.1.75
Upgrade-Insecure-Requests: 1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.2 Safari/605.1.15
Accept-Language: en-GB,en;q=0.9
Accept-Encoding: gzip, deflate
Connection: keep-alive

No. Time Source Destination Protocol Length Info
1948 244.183265 172.16.1.68 172.16.1.75 HTTP 65 POST /settshort.html HTTP/1.1  (application/x-www-form-urlencoded)
1950 244.938642 172.16.1.75 172.16.1.68 HTTP 817 HTTP/1.1 200 OK  (text/html)
a%=> 2buf%() below <========== a%=2 here
geyserIn=80

No. Time Source Destination Protocol Length Info
1988 283.953708 172.16.1.68 172.16.1.75 HTTP 65 POST /settshort.html HTTP/1.1  (application/x-www-form-urlencoded)
1990 284.469144 172.16.1.75 172.16.1.68 HTTP 817 HTTP/1.1 200 OK  (text/html)
a%=> 1buf%() below <========== a%=1 here
geyserIn=80

No. Time Source Destination Protocol Length Info
2021 300.337958 172.16.1.68 172.16.1.75 HTTP 65 POST /settshort.html HTTP/1.1  (application/x-www-form-urlencoded)
2023 300.363091 172.16.1.75 172.16.1.68 HTTP 817 HTTP/1.1 200 OK  (text/html)
a%=> 1buf%() below <========== a%=1 here
POST /settshort.html HTTP/1.1
Host: 172.16.1.75
Origin: http://172.16.1.75
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.2 Safari/605.1.15
Referer: http://172.16.1.75/settshort.html
Content-Length: 11
Accept-Language: en-GB,en;q=0.9

> option list
WebMite MMBasic Version 5.07.07
OPTION COLOURCODE ON
OPTION CPUSPEED (KHz) 264000
OPTION DISPLAY 41, 77
OPTION WIFI **********, **********
OPTION TCP SERVER PORT 80
OPTION TELNET CONSOLE ON

<========== a%=1/2 here indicates that it would appear that the TCP stack has opened two connections for. single web page? Queries are sequential as indicated in the Wireshark packets.

associated settshort.html code below


<html>
   <head>
       <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<!--
       <link rel="preconnect" href="https://fonts.googleapis.com/" crossorigin="true" />
       <link rel="preconnect" href="https://fonts.gstatic.com/" />
       <link rel="stylesheet" href="./set_files/css2" />
-->
       <style>
           undefined
       </style>
   </head>
   <body>
       <h1>CS ECOS Settings</h1>
       <form name="frm" method="post">
           <p>Geyser setpoint (default 80C) {GeyserSetPoint}C</p>
   <input type="text" name="geyserIn" /><input type="submit" value="Submit" /settshort.html>
           </form>
   </body>
</html>


Hopefully this will aid in your response.
Cheers Carl                                                        
Retirement is tough on Hobbies without a day job
 
carlschneider
Senior Member

Joined: 04/08/2023
Location: South Africa
Posts: 158
Posted: 04:04am 01 Sep 2023
Copy link to clipboard 
Print this post

Hi Peter

Took me a while to figure out where I went wrong. The following does not flag as an error and results in what appears to be a lockup and the HW Watchdog didn't seem to catch it. Maybe just something odd on the USB interface and the Watchdog did catch it...maybe I couldn't tell at the time?


Select case string$
Case "test1"
If variable1=variable2 variable1=variable5 'forgot the Then
Case "test2"
If variable3=variable4 variable=variable6 'forgot the Then
End Select


I expected an Abort to Command prompt with an error line.

It seemed to be related to there being two of these errors sequentially. If I REM'ed out the middle one of three then it ran without showing an error but did have unexpected results.
Cheers Carl                                                        
Retirement is tough on Hobbies without a day job
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9127
Posted: 10:40am 01 Sep 2023
Copy link to clipboard 
Print this post

This is one for Geoff as the relevant code is common across all variants of MMBasic. However, there are many potential areas where bugs in Basic code are not detected by the parser. It is almost impossible to detect every error so I would just chalk this one up to experience.
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3194
Posted: 11:24pm 01 Sep 2023
Copy link to clipboard 
Print this post

Yes, Peter is right.  It is impossible for MMBasic to pick up every programmer error and give an appropriate error message.  

It recognises most common errors but, given the way that the BASIC language works and the memory constraints of microcontrollers, it still misses a fair few, gets confused and gives a nonsensical result.  This is part of running an interpreter on a microcontroller.

Geoff
Geoff Graham - http://geoffg.net
 
carlschneider
Senior Member

Joined: 04/08/2023
Location: South Africa
Posts: 158
Posted: 01:48am 02 Sep 2023
Copy link to clipboard 
Print this post

Thanks for the responses Peter and Geoff.

An observation and question about TCP connections if I may...

I keep getting recurring errors at the console, per below, which cause the program to abort to the console and while the heartbeat is beating the program has stopped; notwithstanding the autorun and the HW Watchdog being in operation; I have not used On Error Ignore thus far.

[128] PWM 1, Target,, 50
Error : No response to request from connection no. 0
>


Noting that line [128] has nothing to do with connection no. 0 (?) I then tried to establish a few parameters from the command prompt.

> ?mm.errno
16
> ?mm.errmsg$
No response to request from connection no. 0
> ?mm.info(max connections)
8


The Error : No response to request from connection no. 0 has me puzzled. In the web server example the max connections is stipulated as 8 and the example For Loop runs from 1 to mm.info(max connections). No indication of a connection no. 0.

This begs the questions, what is connection no. 0 and where is it coming from?

Hopefully you can give me some pointers?

As an aid perhaps the Trace List would provide some insights?
> trace list
[130][117][118][119][120][124][128][129][130][117][118][119][120][124][128][129][130][117][118][119][120][124][128][129][130][117][118][119][120][124][128][129][130][117][118][119][120][124][128][129][130][117][118][119][120][124][128][129][130][117][118][119][120][124][128][129][130][117][118][119][120][124][128][129][130][117][118][119][120][124][128][129][130][117][118][119][120][124][128][129][130][117][118][119][120][124][128][129][130][117][118][119][120][124][128][129][130][117][118][119][120][124][128][129][130][117][118][119][120][124][128][129][130][117][118][119][120][124][128][129][130][117][118][119][120][124][128]


The code between line 116 and 130 below

Do
'**********************************************************
'Temporary code to allow Frequency manipulation for testing
 Console$=Inkey$
   If Console$="p" Then
     Target=Target+0.5
     Print Target;" "
   EndIf
   If Console$="l" Then
     Target=Target-0.5
     Print Target;" "
   EndIf
 PWM 1, Target,, 50
'**********************************************************
Loop


I'm looking at this and now asking myself if connection no. 0 is the USB console connection? I've switched to Telnet and will have a look and see if that also gives issues. Option Telnet On (both USB and Telnet enabled) is in use and only the Telnet terminal is running.....
Cheers Carl                                                        
Retirement is tough on Hobbies without a day job
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9127
Posted: 07:47am 02 Sep 2023
Copy link to clipboard 
Print this post

Internally the connections are 0 to MAX CONNECTION-1. The error message should have 1 added.
Will fix in the next beta

So it is connection #1 which is actually giving the error

The error happens if the client opens a connection but then does nothing else within the server response time (default 5 seconds). It is designed to avoid orphaned connections being left open.

The default server response time can be set in the OPTION TCP SERVER PORT portno [,ResponseTimeInMsec]

Because TCP errors happen in the background the reported line number is meaningless, it is just where the program happens to be when the error occured
Edited 2023-09-02 17:48 by matherp
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4043
Posted: 08:59am 02 Sep 2023
Copy link to clipboard 
Print this post

Thanks Peter,

  matherp said  1. You can use BLIT LOAD to populate from a bmp file reading all of it or a subsection into the blit buffer. I could easily add BLIT CREATE to make an empty buffer and then MM.INFO(BLIT ADDRESS n) to return the address if it is genuinely useful. The buffer is in RGB888 format.

2. No chance - big work, but if you want to code it I'll include it. The guts are there in the VGA code but need a lot of integrating. It would be somewhat slower but obviously save memory.


Thank you for the pointer to BLIT LOAD.

Regarding the rest I will wait until I'm actually writing a program that needs the functionality and then try to add the extensions myself.

Best wishes,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
carlschneider
Senior Member

Joined: 04/08/2023
Location: South Africa
Posts: 158
Posted: 02:11pm 02 Sep 2023
Copy link to clipboard 
Print this post

Thanks for the response Peter, much appreciated.

The lyrics …there are more questions than answers…. comes to mind :) - apologies.

Is it possible to provide a linkage between the client and its IP address to aid diagnostics? Perhaps including access to the read buffer to understand which client request has been orphaned?

If Web Tcp Messages Off is active should the background closure of the orphaned client cause an abort to console complete with error message? Is it possible to change this behavior?

With regard to the robustness of the TCP stack, what would you consider to be the maximum permissible frequency of HTTP GET requests from a single Client; as in period between requests, notwithstanding the response timeout parameter?

Whether I use USB (more informative error message) or Telnet (no indication of problem, until a response is elicited and then only indicates an error that session has been closed by the host) I experienced the same abort to console. I now understand the cause and meaning of the error message.

Have you seen my post/query regarding the HTTP POST headers being stripped out of the read buffer by Web Tcp Read regularly with an occasional one not being stripped; odds are somewhere between 1 in 13-25 of POST header getting through intact to the read buffer.

Thank you for your efforts and guidance.
Cheers Carl                                                        
Retirement is tough on Hobbies without a day job
 
Plasmamac

Guru

Joined: 31/01/2019
Location: Germany
Posts: 554
Posted: 09:26pm 02 Sep 2023
Copy link to clipboard 
Print this post

Can we have the same loaddata@pointer command as cmm2 for the picomite vga ?
Plasma
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6100
Posted: 11:17pm 02 Sep 2023
Copy link to clipboard 
Print this post

Suggestions for new MATH commands, all acting on single dimension arrays.

 
SUB math_power array1!(), pow!, arrayout!(), count%
 LOCAL n%
 FOR n% = MM.INFO(OPTION BASE) TO count%
   arrayout!(n%)= array1!(n%)^pow!
 NEXT n%
END SUB
 
SUB math_sum array1!(), array2!(), arrayout!(), count%
 LOCAL n%
 FOR n% = MM.INFO(OPTION BASE) TO count%
   arrayout!(n%)= array1!(n%) + array2!(n)
 NEXT n%
END SUB
 
SUB math_divide array1!(), array2!(), arrayout!(), count%
 LOCAL n%
 FOR n% = MM.INFO(OPTION BASE) TO count%
   arrayout!(n%)= array1!(n%) / array2!(n%)
 NEXT n%
END SUB
 
SUB math_multiply array1!(), array2!(), arrayout!(), count%
 LOCAL n%
 FOR n% = MM.INFO(OPTION BASE) TO count%
   arrayout!(n%)= array1!(n%) * array2!(n%)
 NEXT n%
END SUB


I had the need for a couple of these while I was experimenting with the ADC features and would appreciate the speed improvement having then built-in would give.

Jim
VK7JH
MMedit   MMBasic Help
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4247
Posted: 08:40am 03 Sep 2023
Copy link to clipboard 
Print this post

Jim,

Is the math multiply new, there is already a multiply that works on 2 multidimensional arrays, but could just as well work on single dimensional.

Volhout
PicomiteVGA PETSCII ROBOTS
 
NPHighview

Senior Member

Joined: 02/09/2020
Location: United States
Posts: 200
Posted: 05:54pm 03 Sep 2023
Copy link to clipboard 
Print this post

This is getting awfully close to Map/Reduce - an actual 21st century computing metaphor. In it, a function (here, add, multiply, divide, etc.) gets applied to each element in an array or list, and then some summarizing function (min, max, sum, range, etc.) gets applied to the whole list of results.

Yay!
Edited 2023-09-04 03:56 by NPHighview
Live in the Future. It's Just Starting Now!
 
carlschneider
Senior Member

Joined: 04/08/2023
Location: South Africa
Posts: 158
Posted: 11:29pm 03 Sep 2023
Copy link to clipboard 
Print this post

Hi Peter and Geoff

  Quote  
Have you seen my post/query regarding the HTTP POST headers being stripped out of the read buffer by Web Read regularly with an occasional one not being stripped; odds are somewhere between 1 in 13-25 of POST header getting through intact to the read buffer.


I decided to try Geoff's retic.bas v1.2 as a known working program that uses the web sever. I found that relic.bas would not run either and looking at the read buffer it was again apparent that the POST headers were being stripped in the WEB READ a%, buffer%() process.

I then tried retic.bas v1.2 on Chrome and things starting working properly and the Read buffer contained the full Header set. Reverting back to my current development it too worked in Chrome. Therefore it would appear  that something in the way Safari (16.2) assembles the HTTP headers is upsetting the MMBAsic Web Read routine.

Just to make sure the problem was with Safari and not the laptop I tried using Safari (16.6) on the iPad which behaved in the same way as the laptop. I didn't seem to have any success with Chrome (116.0.5845.118) on the iPad either.

So I switched to using GET only for all interactions, notwithstanding the less secure url-encoded data transfer and now have it working on Safari on both the laptop and the iPad.

Thank you both
Cheers Carl                                                        
Retirement is tough on Hobbies without a day job
 
carlschneider
Senior Member

Joined: 04/08/2023
Location: South Africa
Posts: 158
Posted: 11:34pm 03 Sep 2023
Copy link to clipboard 
Print this post

Is there a chance for a comment block designator similar to html?

<--
comment block start
comment block end
-->

When developing in the EDITor its handy to be able to comment out large blocks of code.
Cheers Carl                                                        
Retirement is tough on Hobbies without a day job
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6798
Posted: 07:27am 04 Sep 2023
Copy link to clipboard 
Print this post

I don't think that would be possible in the internal editor as you would probably require the equivalents of REM and /REM and there isn't room in the command table. ' and REM are the same command. matherp may surprise me though. lol

You could do it in an external editor but you would need to handle the block so that it isn't sent to the MMBasic device.
Edited 2023-09-04 17:28 by Mixtel90
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4043
Posted: 07:56am 04 Sep 2023
Copy link to clipboard 
Print this post

IF 0 THEN
   Code to ignore
   ...
ENDIF


Best wishes,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9127
Posted: 01:24pm 04 Sep 2023
Copy link to clipboard 
Print this post

V5.07.08b15

https://geoffg.net/Downloads/picomite/PicoMite_Beta.zip

Now includes full support for multiline comments

Use /*  to start a comment
Use */ to end a comment

This should be properly supported including colour coding in the editor but note
/* and */ must be the first non-space characters at the start of a line and have a space or end-of-line after them (i.e. they are MMBasic commands)
Any characters after */ on a line are also treated as comment

I'm quite pleased with this. Note in the editor how the colour coding of the whole page changes as you enter or delete the multiline comment chatacters


Edited 2023-09-04 23:28 by matherp
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6798
Posted: 02:14pm 04 Sep 2023
Copy link to clipboard 
Print this post

Didn't I say? I just *knew* it....  :)

Great job, Peter. :)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
carlschneider
Senior Member

Joined: 04/08/2023
Location: South Africa
Posts: 158
Posted: 04:49pm 04 Sep 2023
Copy link to clipboard 
Print this post

  matherp said  
Now includes full support for multiline comments


Thanks Peter, much appreciated.

  thwill said  
IF 0 THEN
  Code to ignore
  ...
ENDIF


I was using Sub when things got out of hand. Now I have a few orphaned sub routines :)

Sub Ignore
Code to ignore
...
End Sub

Cheers Carl                                                        
Retirement is tough on Hobbies without a day job
 
carlschneider
Senior Member

Joined: 04/08/2023
Location: South Africa
Posts: 158
Posted: 04:56pm 04 Sep 2023
Copy link to clipboard 
Print this post

An observation regarding the install of b15.

After installing b15 and F4 all the OPTION had turned into SYNC. Fortunately I made a back up of the .bas program which I then TFTP PUT and LOADed and all working fine now.

Maybe related to shifting things around in the Command Table?

Peter does this beta include the fix for the error message?
  matherp said  
Internally the connections are 0 to MAX CONNECTION-1. The error message should have 1 added.
Will fix in the next beta

Cheers Carl                                                        
Retirement is tough on Hobbies without a day job
 
     Page 8 of 11    
Print this page
© JAQ Software 2024