New serial terminal WEB to test

All that relates to the Annex Toolkit Utility
User avatar
cicciocb
Site Admin
Posts: 1900
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 407 times
Been thanked: 1271 times
Contact:

Re: New serial terminal WEB to test

Post by cicciocb »

I did the testing using the ESP32; it should be the same for the ESP8266.
What is the version of annex that you are using?

You are right, the line that is involved is

Code: [Local Link Removed for Guests]

A$ = A$ + | connection.send("cmd:setvarxd$="+ e); | ' send what received in the variable d$
Maybe you can do some testing, if you are familiar with the "debug" window of the navigator (F12 key).
You could type, in the console, the command
connection.send("cmd:setvarxd$=hello")
and see if you have the same error or you receive "hello" inside the variable d$ ?
This is the way that enable the transfer of variables between javascript and basic.

I need to make some testing on the ESP8266, I cannot do now, I'll try later tonight.
yama
Posts: 27
Joined: Fri Sep 16, 2022 1:42 pm
Been thanked: 3 times

Re: New serial terminal WEB to test

Post by yama »

I tried to debug on chrome.
WiFitermTest01.jpg
"cmd:setvarxd$=hello" is bad.?
parameter (command format) on "connection.send()" is bad?
because japanese key chracter map ?
What is the format on connection.send() ?
You do not have the required permissions to view the files attached to this post.
User avatar
cicciocb
Site Admin
Posts: 1900
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 407 times
Been thanked: 1271 times
Contact:

Re: New serial terminal WEB to test

Post by cicciocb »

This command is different from the esp32 so this line should be

Code: [Local Link Removed for Guests]

A$ = A$ + |   connection.send('cmd:immediatxd$="'+ e + '"'); | ' send what received in the variable d$
So, the complete program should be :

Code: [Local Link Removed for Guests]

cls

'loads the javascript
jsexternal "/xterm.js"
pause 2000 ' a little pause for loading the javascript

A$ = ||
A$ = A$ + |<!doctype html>|
A$ = A$ + | <html>|
A$ = A$ + | <head>|
A$ = A$ + | <link rel="stylesheet" href="/xterm.css" />| 
A$ = A$ + | </head>|
A$ = A$ + | <body>|
A$ = A$ + | <H1> Wifi Xterm Test </H1>|
A$ = A$ + | <div id="terminal"></div>|
A$ = A$ + | </body>|
A$ = A$ + | </html>|
html a$

a$ = ||
A$ = A$ + | term = new Terminal();|
A$ = A$ + | term.open(document.getElementById('terminal'));|
A$ = A$ + | term.write('Hello from \x1B[1;3;31mxterm.js\x1B[0m $ ');|

A$ = A$ + | term.onData(async function(e) { |
A$ = A$ + |   console.log("onData:", e); |
' this line is for the esp32
'A$ = A$ + |   connection.send("cmd:setvarxd$="+ e); | ' send what received in the variable d$
' this line is for the esp8266
A$ = A$ + |   connection.send('cmd:immediatxd$="'+ e + '"'); | ' send what received in the variable d$

A$ = A$ + | });|
jscript a$

OnHtmlChange Jump1  'will jump to Jump1 when a variable changes on the web page
onSerial serialIn ' will jump to serialIn when data received on the serial port
Wait         'pause waiting for the event

Jump1:
Print d$; 'print the characters received in the serial port
Return

serialIn:
jscall |term.write('| + serial.input$ + |');| 'send what received in the web terminal
return
yama
Posts: 27
Joined: Fri Sep 16, 2022 1:42 pm
Been thanked: 3 times

Re: New serial terminal WEB to test

Post by yama »

Thank you for information.
My RDS version is Annex WiFi 1.43.2.(ESP8266) now.
I think that it(wifi term) does not work stably.
What version is suitable for this.
User avatar
cicciocb
Site Admin
Posts: 1900
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 407 times
Been thanked: 1271 times
Contact:

Re: New serial terminal WEB to test

Post by cicciocb »

The latest version is the 1.44.2

[Local Link Removed for Guests]
yama
Posts: 27
Joined: Fri Sep 16, 2022 1:42 pm
Been thanked: 3 times

Re: New serial terminal WEB to test

Post by yama »

Thank you for more information.
Finally it worked good. It is amazing !!
I will try to arrange it a little.
I will report later.
yama
Posts: 27
Joined: Fri Sep 16, 2022 1:42 pm
Been thanked: 3 times

Re: New serial terminal WEB to test

Post by yama »

An error occurred in the input " (double quotes) .
Is there any improvement?

connection.send('cmd:immediatxd$="'+ e + '"');
               
What format is "cmd"?
cmd:immediatex d$=xx ?
xx:double quotes code """ is bad
WiFitermTest02.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
cicciocb
Site Admin
Posts: 1900
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 407 times
Been thanked: 1271 times
Contact:

Re: New serial terminal WEB to test

Post by cicciocb »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Sun Oct 02, 2022 1:03 am An error occurred in the input " (double quotes) .
Is there any improvement?

connection.send('cmd:immediatxd$="'+ e + '"');
               
What format is "cmd"?
cmd:immediatex d$=xx ?
xx:double quotes code """ is bad
WiFitermTest02.jpg
The command cmd: is the way I implemented to transfer commands from javascript to the basic.

cmd:immediatx enables to send command lines as if executed directly from the interpreter.
In this case, the line that is sent is
d$="x" where x is the code of the key typed in the terminal; obviously if the code is " then the line will be d$=""" that gives a syntax error.
What you can do is to use the | as string separator like this :
cmd:immediatxd$='|'+ e + '|');

Code: [Local Link Removed for Guests]

A$ = A$ + "   connection.send('cmd:immediatxd$=|'+ e + '|'); " 
Obviously you'll have the same issue on the key | so, another way, could be to check if the string received contains " and send alternatively the " or the | as separator

Another problem is linked to the character new line '\n' or chr$(10) that is used as line separator so will generate another problem.
You can filter them in the basic like below

Code: [Local Link Removed for Guests]

cls

'loads the javascript
jsexternal "/xterm.js"
pause 2000 ' a little pause for loading the javascript

A$ = ||
A$ = A$ + |<!doctype html>|
A$ = A$ + | <html>|
A$ = A$ + | <head>|
A$ = A$ + | <link rel="stylesheet" href="/xterm.css" />| 
A$ = A$ + | </head>|
A$ = A$ + | <body>|
A$ = A$ + | <H1> Wifi Xterm Test </H1>|
A$ = A$ + | <div id="terminal"></div>|
A$ = A$ + | </body>|
A$ = A$ + | </html>|
html a$

a$ = ||
A$ = A$ + | term = new Terminal();|
A$ = A$ + | term.open(document.getElementById('terminal'));|
A$ = A$ + | term.write('Hello from \x1B[1;3;31mxterm.js\x1B[0m $ ');|

A$ = A$ + | term.onData(async function(e) { |
A$ = A$ + |   console.log("onData:", e); |
' this line is for the esp32
'A$ = A$ + |   connection.send("cmd:setvarxd$="+ e); | ' send what received in the variable d$
' this line is for the esp8266
'A$ = A$ + |   connection.send('cmd:immediatxd$="'+ e + '"'); | ' send what received in the variable d$
'A$ = A$ + "   connection.send('cmd:immediatxd$=|'+ e + '|'); " 
A$ = A$ + |   if (e.includes('"')) |
A$ = A$ + "      connection.send('cmd:immediatxd$=|'+ e + '|'); " ' send what received in the variable d$ using |
A$ = A$ + |   else|
A$ = A$ + |      connection.send('cmd:immediatxd$="'+ e + '"'); | ' send what received in the variable d$ using "
A$ = A$ + | });|
jscript a$

OnHtmlChange Jump1  'will jump to Jump1 when a variable changes on the web page
onSerial serialIn ' will jump to serialIn when data received on the serial port
Wait         'pause waiting for the event

Jump1:
d$ = replace$(d$, chr$(10), chr$(10) + chr$(13))
Print d$; 'print the characters received in the serial port
Return

serialIn:
k$ =  serial.input$
k$ = replace$(k$, chr$(10), "\n")
k$ = replace$(k$, chr$(13), "\r")
jscall |term.write('| + k$ + |');| 'send what received in the web terminal
return
yama
Posts: 27
Joined: Fri Sep 16, 2022 1:42 pm
Been thanked: 3 times

Re: New serial terminal WEB to test

Post by yama »

"Wifi-Terminal" work perfectly, do same as Web-Terminal.
Amazing! Wireless terminal is completed!
Annex-RSD is "cool" system.
WiFiTermTest05-2.jpg
WifiTerm_IoTPod(ESP8266)_for_SkyBerryJAM-2.jpg
I will arrange it a little more,
Recently, I plan to embed it in a programming robot for learnning.
Thank you.
You do not have the required permissions to view the files attached to this post.
User avatar
cicciocb
Site Admin
Posts: 1900
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 407 times
Been thanked: 1271 times
Contact:

Re: New serial terminal WEB to test

Post by cicciocb »

Nice!! :D
Post Reply