Page 4 of 5

Re: New serial terminal WEB to test

Posted: Fri Sep 30, 2022 3:00 pm
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.

Re: New serial terminal WEB to test

Posted: Sat Oct 01, 2022 8:05 am
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() ?

Re: New serial terminal WEB to test

Posted: Sat Oct 01, 2022 8:26 am
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

Re: New serial terminal WEB to test

Posted: Sat Oct 01, 2022 11:38 am
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.

Re: New serial terminal WEB to test

Posted: Sat Oct 01, 2022 11:48 am
by cicciocb
The latest version is the 1.44.2

[Local Link Removed for Guests]

Re: New serial terminal WEB to test

Posted: Sat Oct 01, 2022 3:12 pm
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.

Re: New serial terminal WEB to test

Posted: Sun Oct 02, 2022 1:03 am
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

Re: New serial terminal WEB to test

Posted: Sun Oct 02, 2022 6:25 am
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

Re: New serial terminal WEB to test

Posted: Sun Oct 02, 2022 9:42 am
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.

Re: New serial terminal WEB to test

Posted: Sun Oct 02, 2022 10:33 am
by cicciocb
Nice!! :D