Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 17:01 17 May 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 : MMB4L: MMBasic for Linux alpha release

     Page 8 of 11    
Author Message
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2294
Posted: 11:23am 16 Jan 2022
Copy link to clipboard 
Print this post

hi Tom,
   just gave the 64-bit Linux version a quick spin - it works nicely, running several simple test programs. excellent work  

may i suggest allowing the user to configure a different editor? i have a personal hate of 'nano', much preferring to use 'xed' which is bundled with mint/xfce. i don't know what other distros have 'xed' included - it is a simple gui-based editor that places nicely when called from a command window.

it would also be handy if 'cd' was an alias for 'chdir' at the command prompt, and if tab filename completion could somehow be hacked into the command prompt. although i could see that being quite a bit of effort to make it work!


cheers,
rob   :-)
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3863
Posted: 11:51am 16 Jan 2022
Copy link to clipboard 
Print this post

Thanks for checking it out Rob,

I'll make a note of your suggestions but alpha 4 is likely to just consist of the inevitable fixes for serial comms plus some software buffering for transmit; currently it just uses the very small hardware buffer. I also need to check out whether @lizby has any GPIO, I2C and SPI stuff for me to integrate.

Note I never planned it, but I've discovered that the real "secret" to productivity with MMB4L is, except where debugging, to use the Linux console (and its comprehensive commands) for the majority of operations rather than the MMBasic console. Then use whatever editor you want and RUN program "abc.bas" by typing:

mmbasic -i abc.bas

instead of:

RUN "abc.bas"

This works because MMB4L automatically reloads .bas files before any operations where it might matter.

Going beyond this, if you are using a rich modern code editor such as VScode you can hook up its "Execute/Run" action to automatically run .bas files with MMB4L.

Add to that the ability to have multiple Linux consoles each running their own MMB4L instance and I've accidentally created something useful .

Best wishes,

Tom
Edited 2022-01-16 22:40 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
mobluse

Newbie

Joined: 10/02/2013
Location: Sweden
Posts: 24
Posted: 02:39am 17 Jan 2022
Copy link to clipboard 
Print this post

It might be a good idea to follow the options of python3 --help. E.g. -i means load and run the program and then drop to interactive prompt. If you just have the file it runs the program and then exits. In BASIC you might want to just load a program and not run it in order to just LIST it. In that case you could use: mmbasic -i -m program.bas because code loaded using -m is not run.

It would also be good if MMBasic code could be used as CGI programs for web servers.
Maker Pi Pico Rev1.2, DuinoMite-Mini, Raspberry Pi 0-4, iCE40HX8K, Arduino Uno, VM111, STK500, ZX81
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3863
Posted: 11:13am 17 Jan 2022
Copy link to clipboard 
Print this post

Hi @mobluse,

  mobluse said  It might be a good idea to follow the options of python3 --help. E.g. -i means load and run the program and then drop to interactive prompt. If you just have the file it runs the program and then exits.


I think that is what I currently have implemented, are you saying otherwise ?

  mobluse said  In BASIC you might want to just load a program and not run it in order to just LIST it. In that case you could use: mmbasic -i -m program.bas because code loaded using -m is not run.


I agree that would be useful but only being a dabbler in Python I wasn't aware of the -m flag, and when I read the documentation it suggests it does something otherthan you suggest .

  mobluse said  It would also be good if MMBasic code could be used as CGI programs for web servers.


It must be 20 years since I wrote a CGI script, do people still do that ? I think it probably works, would someone care to test it ? MMB4L already reads from and writes to STDIN/STDOUT by default so isn't it just a case of adding #!/usr/bin/mmbasic to the top of the .bas file and flagging it as executable ?

Thanks,

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

Joined: 05/03/2018
Location: Netherlands
Posts: 3586
Posted: 12:50pm 17 Jan 2022
Copy link to clipboard 
Print this post

Hi Tom,

Have installed it on my old linux system (ubuntu 16.04). There are some nano (2.5.3) bindings not supported, so I'll make my life easier by using my own preferred editor (mmbasic -i "filename") and edit the file while mmbasic window open.

I will toy with serial ports tonight, but my first feedback on this release is:

1/ console background and foreground are not persistent. After running a program they return to default (grey text on black).

2/ color (brit: colour) mapping in the console command is not optimal. White is grey, yellow is brown. Looks like the old EGA (16 colors) that uses the wrong set of 8 colo(u)rs. All colo(u)rs are less bright.
This is a no brainer for this release that focusses on COM functionality, but just to let you know.

More feedback during the week.

Regards,

Volhout
PicomiteVGA PETSCII ROBOTS
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3863
Posted: 01:10pm 17 Jan 2022
Copy link to clipboard 
Print this post

Hi Volhout,

Thanks for taking an interest.

  Volhout said  Have installed it on my old linux system (ubuntu 16.04). There are some nano (2.5.3) bindings not supported, so I'll make my life easier by using my own preferred editor (mmbasic -i "filename") and edit the file while mmbasic window open.


Yes, it's looking like nano may not have been an optimal choice for the internal editor. Adding OPTION EDITOR may be moving up the priority list. For my notes could you let me know what errors nano 2.5.3 is reporting.

Also please note compatibility with Ubuntu 16 is "accidental". I build on {X}Ubuntu 18 and at some point it's likely the executable will thus get a dependency on GLIBC_2.27 (the default for Ubuntu 18 and its default gcc/libraries.) @lizby and I have already seen this happen on the Pi where despite having both been built on "Buster" (GLIBC_2.28) alpha 2 would work on "Stretch" (GPLIBC_2.17) but alpha 3 requires "Buster".

  Volhout said  1/ console background and foreground are not persistent. After running a program they return to default (grey text on black).


Yes, and I'm not sure if they should be. Personally I like to have the defaults restored when returned to the MMBasic prompt, but I can see arguments to the contrary - especially if you choose to CONTINUE (but note that you may still be in trouble because any interrupts will have been cleared when MMB4L drops to the prompt).

  Volhout said  2/ color (brit: colour) mapping in the console command is not optimal. White is grey, yellow is brown. Looks like the old EGA (16 colors) that uses the wrong set of 8 colo(u)rs. All colo(u)rs are less bright.


I believe that is your terminal as some variation is allowed, see https://en.wikipedia.org/wiki/ANSI_escape_code#3-bit_and_4-bit. I'm sending the standard 16-colour control codes. The Ubuntu 20 terminal preferences allows you to choose between different standard colour schemes/mappings - it sounds like you might be using the one it describes as "Linux console".

Best wishes,

Tom
Edited 2022-01-17 23:34 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 3586
Posted: 02:56pm 17 Jan 2022
Copy link to clipboard 
Print this post

Hi Tom,

The colours I see most resemble the first 8 VGA colours. Anyway, I think this is caused by my terminal program.

Reason I use (L)ubuntu 16.04 LTS is because of it's stability. This is caused by the fact that Lubuntu (since 13.10) aimed to replace LXDE with LXQT (razorQT). And every release since they failed to make the change because it was complicated, there where bugs, etc... As result they continued bug fixes to the LXDE release (no changes, just bugfixes) for 3 years (6 releases). This version Lubuntu (16.04.6) is the last of that line of bugfixes, it simply is unbreakable.

LXQT appears in Lubuntu 18.04 LTS, and due to changes and changes and changes the 20.04 LTS is not even backwards compatible anymore with 18.04. And what is more: they officially left the path of "leanest Ubuntu distro", and are packing the distro with heavy armour (i.e. Libreoffice), so the iso changed from 800Mbyte several Gbyte. That makes them unattractive for me. They must compete now with Ubuntu MATE, the various MINT distro's, ZORIN, elementary OS, Ubuntu main and the rest of the pack. I foresee Lubuntu diminish. The competitive edge is gone.

Yes, I know 16.04 is not updated anymore. But it simply works.

Volhout
PicomiteVGA PETSCII ROBOTS
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 3586
Posted: 06:41pm 17 Jan 2022
Copy link to clipboard 
Print this post

Dear Tom,

1/ the bindings that where missing are:
> edit "comtest.bas"

Error in /home/school/.nanorc on line 12: Unknown option "zap"

Error in /home/school/.nanorc on line 31: Cannot map name "copy" to a function

Error in /home/school/.nanorc on line 32: Cannot map name "zap" to a function

Error in /home/school/.nanorc on line 33: Cannot map name "paste" to a function

Error in /home/school/.nanorc on line 44: Cannot map name "constantshow" to a function

Error in /home/school/.nano/mmbasic.syntax.nanorc on line 6: Command "comment" not understood

Press Enter to continue starting nano.


2/ My first take on the serial communication. I have 2 FTDI USB->serial adapters, and cross wired these. I used Putty on one side, and MMbasic on the other side. I read the characters from the input buffer when LOC(1)>0 and printed them on screen. I noticed there was not much difference between 9600baud and 115200 baud.
Therefore I did an experiment (take the screen printing out of the equasion).

3/ Same setup, but 2 instances of MMBasic, each running it's own program.
The program reads a character, and sends it back.
One of both programs sends the initial character, that will bounce between the 2 MMBasic programs.

Start this program first
'test for com port 1

open "/dev/ttyUSB0: 115200" as #1
i=1
timer=0

do
if loc(1) then
a$=input$(1,#1)
print #1,a$;
i=i+1
if i=1000 then
     i=1
     print timer,8e6/timer;" bps"
     timer=0
      end if
       end if

loop until inkey$<>""

close #1


Then start this program
'test for com port 2

open "/dev/ttyUSB1: 115200" as #1
i=1

print #1,"s"; 'send start value, this initiates an endless tream
timer=0

do
if loc(1) then
a$=input$(1,#1)
print #1,a$;
i=i+1
if i=1000 then
      i=1
     print timer,8e6/timer;" bps"
     timer=0
      end if
       end if

loop until inkey$<>""

close #1


You see on the terminal screen that the actual speed is around 500kbps (this i5 laptop).

> run
15970 500.9392611 bps
15962 501.190327 bps
15962 501.190327 bps
17241 464.0102082 bps
15963 501.15893 bps
15962 501.190327 bps
15963 501.15893 bps
15963 501.15893 bps
16043 498.6598516 bps
17066 468.7683113 bps
16045 498.597694 bps
15960 501.2531328 bps
15963 501.15893 bps


Since the data is bouncing between the 2 programs the actual speed per program is around 1000 bps (based on the baudrate that could have been close to 80000bps).
So there is some overhead in MMBasic. That explains why I did not see much speed difference between 9600 baud and 115200.

Note that in test 2 I had only one instance of MMBasic running.

Maybe this is caused by my system, or the fact that I use an older Lubuntu to test.
I also know the test is heavily hindered by the fact that I am passing character for character. Using buffers would be much faster I estimate. This is something for tomorrow.

More next report,

Volhout
PicomiteVGA PETSCII ROBOTS
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3863
Posted: 08:32pm 17 Jan 2022
Copy link to clipboard 
Print this post

Hi Volhout,

Just a quick response for now.

At the risk of saying something foolish I wonder if what you are really performance testing there is the speed at which MMB4L executes BASIC code rather than anything much to do with serial comms, which afterall only make up 10% of the statements in your example.

It would be interesting to know what result a pair of cross-wired PicoMites running the same code generates - anyone care to try that experiment for me ?

Best wishes,

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

Newbie

Joined: 10/02/2013
Location: Sweden
Posts: 24
Posted: 11:00pm 17 Jan 2022
Copy link to clipboard 
Print this post

It works well on Raspberry Pi 4 B 8 GB (ARM64) and Asus EeePC900 2 GB RAM (x86-33), but I have problems with it on Lenovo Ideapad 100 with Windows 10 and WSL when logging in via ssh, but more about this later; first some other issues.

I think one should be able to interact with environment variables from e.g. Bash or CGI.

I think save would be useful since you can save under another name and chdir and save in another directory.

I could remove a directory using kill even though it says it's an error (which it should be):
Linux armv6l MMBasic Ver 2022.01.00-a3
Copyright 2011-2022 Geoff Graham
Copyright 2021-2022 Thomas Hugo Williams

> name "test.bas" as "test2.bas"
Error: Unknown command
> mkdir "mydir"
> files
aritm-mm.bas  ChangeLog  mmbasic  mmbasic.nanorc  mmbasic.syntax.nanorc  mydir README.md  test.bas

> kill "mydir"
Error: Is a directory
> rmdir "mydir"
Error: No such file or directory
> files
aritm-mm.bas  ChangeLog  mmbasic  mmbasic.nanorc  mmbasic.syntax.nanorc  README.md  test.bas

> mkdir "mydir"              
> files
aritm-mm.bas  ChangeLog  mmbasic  mmbasic.nanorc  mmbasic.syntax.nanorc  mydir README.md  test.bas

> rmdir "mydir"
> files
aritm-mm.bas  ChangeLog  mmbasic  mmbasic.nanorc  mmbasic.syntax.nanorc  README.md  test.bas


I also run it on Lubuntu 18.04:
Linux i686 MMBasic Ver 2022.01.00-a3
Copyright 2011-2022 Geoff Graham
Copyright 2021-2022 Thomas Hugo Williams

> files
ChangeLog  mmbasic  mmbasic.nanorc  mmbasic.syntax.nanorc  README.md

>

whithout problems using ssh from my Raspberry Pi.

Then I run it in WSL Ubuntu 18.04 under Windows 10 using ssh from my Raspberry Pi, but then I had problems with lagging keypresses in MMBasic that were not in WSL. The charcter for a keypress shows up one or several keypresses later. It starts when I do files or list commands then it gets worse as a type more commands.
Linux x86_64 MMBasic Ver 2022.01.00-a3
Copyright 2011-2022 Geoff Graham
Copyright 2021-2022 Thomas Hugo Williams

> files
ChangeLog  mmbasic  mmbasic.nanorc  mmbasic.syntax.nanorc  README.md

>
> files
ChangeLog  mmbasic  mmbasic.nanorc  mmbasic.syntax.nanorc  README.md


I have to press Enter several times and then one earlier typed character appears at a time. I have Ubuntu 18.04 for WSL:
$ uname -a
Linux ideapad100 4.4.0-19041-Microsoft #1237-Microsoft Sat Sep 11 14:32:00 PST 2021 x86_64 x86_64 x86_64 GNU/Linux

and this Windows 10:
>ver

Microsoft Windows [Version 10.0.19043.1415]

Maker Pi Pico Rev1.2, DuinoMite-Mini, Raspberry Pi 0-4, iCE40HX8K, Arduino Uno, VM111, STK500, ZX81
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3863
Posted: 11:21pm 17 Jan 2022
Copy link to clipboard 
Print this post

Hi @mobluse,

Thanks for the testing.

  mobluse said  I think one should be able to interact with environment variables from e.g. Bash or CGI.

Do you mean other than reading them with MM.INFO$(ENVVAR "foo") ?

  mobluse said  I think save would be useful since you can save under another name and chdir and save in another directory.

Coincidentally that use-case occurred to me earlier today, at the moment you'd have to use COPY. I'll have to consider it.

  mobluse said  I could remove a directory using kill even though it says it's an error (which it should be)

Thanks, that probably happened because I'm mixing and matching with code from the CMM2 which only has KILL (not RMDIR) and allows the former to delete directories. Would anyone care to offer an opinion on whether MMB4L should have both KILL and RMDIR ?

  mobluse said  Then I run it in WSL Ubuntu 18.04 under Windows 10 using ssh from my Raspberry Pi ...

OK, I have no experience with WSL (is this WSL 1 or WSL 2, are either now "installed as standard"?). Can you describe the use-case in more detail ? How does the Raspberry Pi come into play ? Can't you interact with WSL directly via a terminal on the Windows 10 machine ?

Best wishes,

Tom
Edited 2022-01-18 10:01 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
mobluse

Newbie

Joined: 10/02/2013
Location: Sweden
Posts: 24
Posted: 03:10am 18 Jan 2022
Copy link to clipboard 
Print this post

I did not know about envvar, but it works with e.g. ?mm.info$(envvar "PATH").

I did not know about copy, but maybe you can modify the program in memory using poke, and then you need to save it.

I guess that kill doesn't work with directories in GW-BASIC is probably a safety feature. The goal with GW-BASIC was probably that you should be able to do everything in it.

I use WSL 1 and the issue is also when I run WSL Ubuntu on the local machine in Microsoft Terminal (from Store) or Command Prompt (built-in cmd.exe). It is not so easy to switch between WSL 1 and WSL 2 and I believe I need some features of WSL 1 such as better support for USB serial ports.

When I connect over ssh I run Microsoft OpenSSH on the Windows 10 machine. However, OpenSSH doesn't seem to be the problem since it also affects the local consoles.

WSL does normally not have these problems; I have never experienced them before. They get worse each time I run files. If you have a x86-64 (x64) Windows 10 computer you might want to try WSL. I have the most updated system (for my hardware) and am not a Windows Insider.
Edited 2022-01-18 18:25 by mobluse
Maker Pi Pico Rev1.2, DuinoMite-Mini, Raspberry Pi 0-4, iCE40HX8K, Arduino Uno, VM111, STK500, ZX81
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 3586
Posted: 08:25am 18 Jan 2022
Copy link to clipboard 
Print this post

Hi Tom,

I do not have 2 picomites anymore, but I do have 2 MX170's (40MHz types).
The test results are:

382     20942.4 bps
382     20942.4 bps
382     20942.4 bps
382     20942.4 bps
382     20942.4 bps
382     20942.4 bps
382     20942.4 bps
381     20942.4 bps
381     20997.4 bps
381     20997.4 bps
381     20997.4 bps
381     20997.4 bps
381     20997.4 bps
381     20997.4 bps


So the 40MHz micromites MX170 = 20   kbps running at 115200bps UART.
The MMB4L interpreter         =  0.5 kbps running at 115200bps UART.
(MMB4L on a i5 2.5GHz Quadcore)

The only change to the code was that I replaced /dev/ttyUSB0 with COM1.

Maybe this is caused by the fact that UART status (LOC()) is passed to MMB4L only once every 16ms or so (VGA tick ?).

Regards,

Volhout
PicomiteVGA PETSCII ROBOTS
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 3586
Posted: 09:24am 18 Jan 2022
Copy link to clipboard 
Print this post

This can be used to test different packet sizes.

'speed test for com port 1

' send data packet with string_length through serial port
' the received data is send back, causing an endless when RX=TX
' or when a second MX170 is connected with same program

string_length=8

' open the serial port without any hardware handshaking
' buffer size should be larger than string length
Open "COM1: 115200" As #1

' send the initial data packet
Print #1,Left$("0123456789ABCDEF",string_length); 'send start value, this initi
ates an endless stream

' initial values for the loop. Needed to calculate the throughput
Timer =0
i=0

' the main loop. Check if data arrived, and output it again to the same serial
' port. User COM1 since it supports 115200 baud on MX170.
Do
 If Loc(1)=string_length Then

   a$=Input$(string_length,#1)
   Print #1,a$;
   i=i+string_length

   If i>=1000 Then
     'only print once every 1000 characters to prevent screen impact on speed
     i=0
     Print 8e6/Timer;" bps"
     Timer =0
   End If

 End If
Loop Until Inkey$<>""

Close #1


With this exact identical program, using 1 serial port, one MMBasic instance in MMB4L, and just RX=TX connection on the serial port.

                             MMB4L            MX170
String_length = 1             500bps           14700bps
String length = 2             1001bps          28250bps
String_length = 4             2009bps          39800bps
String_length = 8             4004bps          59250bps

If you look at the throughput of MMB4L you see that duplication of string length is almost exactly duplication of throughput. This indicates the basic code does not really slow down the processing. There is something else limiting the throughput. The MX170 speed curve does not show the exect duplication at string length 4 and 8 anymore. Here the basic interpreter starts to limit the performance.
Edited 2022-01-18 19:51 by Volhout
PicomiteVGA PETSCII ROBOTS
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2294
Posted: 11:29am 18 Jan 2022
Copy link to clipboard 
Print this post

  Volhout said  [...]
                             MMB4L            MX170
String_length = 1             500bps           14700bps
String length = 2             1001bps          28250bps
String_length = 4             2009bps          39800bps
String_length = 8             4004bps          59250bps
[...]


those packet sizes are pretty small, and likely to leave Linux struggling to achieve the fulls speed of the serial port. remember how many layers of abstraction that will exist between the hardware and a Linux application. in contrast, on an MX170 there will be just a couple of layers at most.

i'd try the same test but with a 250 byte string length, and then work down from there. this should provide you with a far more complete picture.


cheers,
rob   :-)
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3863
Posted: 11:43am 18 Jan 2022
Copy link to clipboard 
Print this post

  robert.rozee said  those packet sizes are pretty small, and likely to leave Linux struggling to achieve the fulls speed of the serial port. remember how many layers of abstraction that will exist between the hardware and a Linux application. in contrast, on an MX170 there will be just a couple of layers at most.

i'd try the same test but with a 250 byte string length, and then work down from there. this should provide you with a far more complete picture.


I was going to say something similar and hope Rob is correct in his analysis because whilst I know that the MMB4L transmit side is lacking, and have some ideas in that respect, I'm not certain what possibilities I've got to improve the receive side ... and in both cases with small packet sizes there is every chance that any "optimisation" will make things worse.

Thanks for all the testing Volhout and the ideas regarding the hardware setup. In the absence of a null-USB cable it hadn't occurred to me to cross-wire two USB/serial adapters or simply use one with RX and TX tied together. My testing so far has all involved juggling another device, either a CMM2 or PicoMite.

Best wishes,

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

Joined: 05/03/2018
Location: Netherlands
Posts: 3586
Posted: 12:49pm 18 Jan 2022
Copy link to clipboard 
Print this post

@Tom, @Robert,

MMB4L: String size 240 characters: 51000bps

That was to be expected, so for larger strings(packets) it is okay.

I was intending to test MMB4L for modbus (smaller packets, half duplex, CRC), but that may not be the best platform. For modbus you check the header (byte for byte) to check the packet length, and then retrieve the packet. But the slow acquisition of the header may not be the best solution. When acquiring byte for byte, 500bps equals 64 bytes per second. That will slow down the modbus significantly.

MMB4L will shine when calculating the CRC.. with quadcore i5.

Regards,

Volhout
PicomiteVGA PETSCII ROBOTS
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2294
Posted: 01:11pm 18 Jan 2022
Copy link to clipboard 
Print this post

Volhout: it is still early days for MMB4L, i'm sure serial buffering is just one area of the code to be filled out.

Tom: do feel free to grab the serial code from GFXterm and make use of it - translation to C should be fairly straightforward. i make use of a separate thread for serial communications (makes life considerably easier), with sizable ring buffers on both Rx and Tx.


cheers,
rob   :-)
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3863
Posted: 01:34pm 18 Jan 2022
Copy link to clipboard 
Print this post

  robert.rozee said  Volhout: it is still early days for MMB4L, i'm sure serial buffering is just one area of the code to be filled out.

Tom: do feel free to grab the serial code from GFXterm and make use of it - translation to C should be fairly straightforward. i make use of a separate thread for serial communications (makes life considerably easier), with sizable ring buffers on both Rx and Tx.


Thanks Rob, you've made that offer before and when I feel the need I will check it out - I'm not deliberately ignoring you it's just that I'm only able to operate at a sedate pace (7 or 8 hrs a week actual implementation) and trying to balance figuring it out myself vs. monkey see, monkey do.

The Rx side already has a (default 4096 byte) ring buffer, but there is not yet a software buffer on the Tx side. Currently I'm filling the Rx buffer in between processing every BASIC statement (and also on demand if a function is called that reads it and it is empty) but the plan is to fill it in a separate thread. Tx will eventually be similar.

On the Rx side I am aware of two optimisations to look at (before the threading):
i) currently I read into a temporary buffer and copy into the ring buffer, that intermediate can be eliminated for what it's worth.
ii) I'm currently polling for data to read in the most naive manner, I need to use select().

With regards to your use-case Volhout (and based on no knowledge whatsoever about modbus) rather than reading 1 character at a time using Input$(1, #1) don't you want to read everything that is available (up to 255 chars) into a String and then process that String a char at a time to read the header and packet, possibly that String will not contain the complete packet (and you will need to ask for more), or it will contain the start of the next header (which you will need to save for later) but you handle all that in MMBasic.

Anyway seems like I've got plenty to get on with when enthusiasm next strikes, at least the basics seem to work .

I'm still interested to know if XONXOFF and RTSCTS work or whether "monkey see, monkey do" has just left me with a heap of primate poo.

Best wishes,

Tom
Edited 2022-01-18 23:40 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3677
Posted: 01:45pm 18 Jan 2022
Copy link to clipboard 
Print this post

The time for the copy is likely irrelevant.

The speed seems very oddly slow, as if we're overlooking something...

John
Edited 2022-01-18 23:47 by JohnS
 
     Page 8 of 11    
Print this page
© JAQ Software 2024