Get Data From Serial Port

Use this section to showcase your programming examples. Or to ask members for programming suggestions
Post Reply
nthornton
Posts: 9
Joined: Wed Jun 14, 2023 1:11 pm

Get Data From Serial Port

Post by nthornton »

I need a routine that gets a character from the serial port buffer , without having to wait or timeout .
I Have tried this routine

#include "rsvars.inc"
CLR B
jsr rst_entry_point
.byte rs$open
jsr rst_entry_point
.byte rs$getchar
psh a
lda B #
jsr rst_entry_point
.byte rs$close
pul a
rts
.end

the opl call is
J%=USR(ADDR(RS%())+1,0)
print j%

but it just returns 1205 , always

Any idea where I'm going wrong
nthornton
Posts: 9
Joined: Wed Jun 14, 2023 1:11 pm

Re: Get Data From Serial Port

Post by nthornton »

Finally Figured it out .

#include "rsvars.inc"
clr b
RS rs$open
RS rs$getchar
psh a
lda B #
RS rs$close
pul a
tab
clr a
xgdx
rts
.end

so we need to return the value in X ,
the ascii code recived is in A
so we need to put A into B , Clear B and then swap to X and return

this allows a continuous loop scanning the keyboard and serial port and will act on what ever event happens first .
the plan is to implement the matrix orbital code (which already works) and send the keyboard strokes back to the pc software.
the pc software can display rss feeds , weather , cpu info etc , and also act as a keyboard to send macros, launch programs etc , kind of like a steam deck
MartinP
Posts: 46
Joined: Wed Jan 04, 2023 7:51 pm

Re: Get Data From Serial Port

Post by MartinP »

This is interesting, I'm not seeing any keyboard system calls in your code? What's the matrix orbital code you mentioned?
Martin P.
nthornton
Posts: 9
Joined: Wed Jun 14, 2023 1:11 pm

Re: Get Data From Serial Port

Post by nthornton »

so the matrix orbital is the manufacturer of a series of serial controlled lcd displays , they are popular because they can be sent instructions via rs232 and are completely stand alone , the use cases were pc info displays , which show cpu usage , network bandwidth etc , there was a long time ago a program called lcd smarty , which would also display Winamp track info , rss feeds etc ,I guess its like a psion display on a pc , which is why I thought , lets just use the psion , its got a display and a keyboard , so we could in theory , use it as a remote display and keyboard for a pc application .

in order to achieve this we have to go in a loop and poll both the serial port and the keyboard on the psion , if a character comes from the serial port , we decode the instructions and generate the display , matrix orbital codes are either plain text or have special instructions that start with byte 254.
such as move the cursor to x,y or clear the display etc.
however if we press a key we want to send this and have the software perform an action .
take a scenario such as the psion currently displays the clock and date , we press o and this fries an outlook macro , the display changes to launching outlook , and the desktop software launches the program .
or we press m and enter keyboard macro mode , then each key press will tell the pc to generate keyboard events or macros such as logging in to a server.

so far I have the basics of the matrix , display code in opL , the problem with OPL is that we could only wait for a character from the serial port before timing out , that means when we press a key , it mostly goes unnoticed and the response is laggy and horrible , the assembly routine now allows the loop to run and act in a more spritely manner .

if anyone is interested in the finished article , I suppose I could make a pack image for the psion and an installer for the pc , I am coding the PC side of things in visual studio using c#
MartinP
Posts: 46
Joined: Wed Jan 04, 2023 7:51 pm

Re: Get Data From Serial Port

Post by MartinP »

Sounds great! And yes, please share it when you're done.
Martin P.
nthornton
Posts: 9
Joined: Wed Jun 14, 2023 1:11 pm

Re: Get Data From Serial Port

Post by nthornton »

posted inital, early version in program packs , currently working with lcdsmartie
Post Reply