I want to use rs232 keyboard in OPL

Use this section to showcase your programming examples. Or to ask members for programming suggestions
Post Reply
Daren
Posts: 58
Joined: Tue Jan 03, 2023 10:03 pm

I want to use rs232 keyboard in OPL

Post by Daren »

Has anyone written any OPL snippet for alphanumeric input over the comms link?

I want to try to incorporate remote keystrokes over the comm port, but not sure if that is possible?

If any members have done this before or have some suggestions or code snippet I’d appreciate it.

Thanks!
amenjet
Posts: 200
Joined: Tue Jan 03, 2023 7:54 pm

Re: I want to use rs232 keyboard in OPL

Post by amenjet »

The Psion has a lot of hooks into the ROM code so it should be possible to do this. For instance:

bta_poll 205A/5B This vector points to the routine which polls the keyboard. It must return the number of the key pressed in the A register. The ROM routine returns 0 if no key was pressed, or a number from 1 to 36 otherwise. If the shift key is not disabled (see kbb_shfk, $20C4) and the shift key is pressed, the routine will set the shift flag (bit 7 of bta_stat, $7B) and return the number of the second key pressed if there is one.

using this vector you could check for a serial character and return a keycode if there is one, or if there is none call the original keypad polling routine. Not OPl, and I'm not sure that this is possible in OPL.
MartinP
Posts: 46
Joined: Wed Jan 04, 2023 7:51 pm

Re: I want to use rs232 keyboard in OPL

Post by MartinP »

Andrew's tip would allow you to use serial to act as if the Psion's keyboard has been pressed, so would be a powerful way to externally control the Organiser, but to implement it would require some machine code.

However, if you just want to read serial text into OPL you could use LINPUT$:() which is described in the Comms Link manual. There's an OPL example in the MP3 player driver I wrote, where I read input from serial, see here: viewtopic.php?t=25 I was reading data packets of fixed size, so this example is more complex than just reading text, but the principle is the same.
Martin P.
Daren
Posts: 58
Joined: Tue Jan 03, 2023 10:03 pm

Re: I want to use rs232 keyboard in OPL

Post by Daren »

Thanks gents.

Andrew, machine code is something I never could wrap my head around, to be truthful I struggle even with OPL, but as always appreciate you sharing the knowledge.

Martin, I looked in the programming manual but I didn’t think to check the comms link manual, thanks for that, LINPUT$ looks like it might do the trick indeed.
User avatar
Martin
Global Admin
Posts: 220
Joined: Mon Jan 02, 2023 5:18 pm

I want to use rs232 keyboard in OPL

Post by Martin »

Hi Daren

Andrew and MartinP are correct that it should be possible.

Could you give me a little more information. Are you looking to 'send' a variable for an INPUT in an OPL routine (LINPUT:()) or perhaps some 'text' in a notepad or even the contents of a file record (Comms Terminal)? Or are you looking to 'drive' the organiser keyboard with a PC keyboard via the Comms Link?

Sincerely
Martin
Daren
Posts: 58
Joined: Tue Jan 03, 2023 10:03 pm

Re: I want to use rs232 keyboard in OPL

Post by Daren »

Martin, I was thinking of trying to use the external keyboard for a few things, one of which I don’t think possible now that I have looked into it - to use it for typing notes directly into notepad, from what I understand the only Psion data files which can be fully used in OPL is the database files, so that probably isn’t possible.

But I have written a couple of simple programs which accept (local) key strokes and thought it might be useful to control those via the comms link, which it seems may be possible.

I have successfully been using a Tandy TRS80 Model100 portable computer to write notes and send those to the Psion, so the notepad rs232 direct keyboard entry isn’t important but would have been handy.

I have also been experimenting with connecting a microcontroller to the comms link, and managed to get two way communication between the Psion and the microcontroller, just really basic things like turning on LEDs or reading sensor values, currently only in the terminal app but eventually hope to get a data logger thing working in OPL which will read the data over the comms link at specified intervals.

Just a bit of layman “tinkering” projects really, nothing in the league of what some of you guys are doing.
User avatar
Martin
Global Admin
Posts: 220
Joined: Mon Jan 02, 2023 5:18 pm

I want to use rs232 keyboard in OPL

Post by Martin »

Hi Daren

While you are considering your options check out (ORG-Link) lostgallifreyan is a member here and will no doubt comment when he reads this..

Check out the [Port Relay] - I've never used it but the information page suggests 'It is bi-directional, passing data and flow control signals' - it may help. I do use [File Relay] which is great for passing text from the Organiser to a PC so if the port relay is as good it will do what you want.

Also see page 64 of the republished (Comms Link Manual) where you will see that on an LZ/LZ64 you can save the data from the capture buffer to a data file, procedure or in your case Notepad file.

Keep us posted on how you get on.
Sincerely Martin
Lostgallifreyan
Posts: 83
Joined: Thu Jan 12, 2023 8:25 pm

Re: I want to use rs232 keyboard in OPL

Post by Lostgallifreyan »

Martin wrote: Sun Mar 03, 2024 1:10 am Hi Daren

While you are considering your options check out (ORG-Link) lostgallifreyan is a member here and will no doubt comment when he reads this..
I will try... :) If the Comms Link is to be used to input to a specific program, it can be done, using a looped LINPUT$: to get each character while not interrupting program flow so it can test for other events like local keys (and precede with LINPUT$:(0) to flush spurious signals before capturing the character you want). A more generally useful method may be possible, based on Jaap's 'KEYS' TSR, if it is modified to read key codes input from the comms link, but I don't know enough to do this.

ORG-Link's port relay probably won't help with this because it's a simple thing, a bit like a MIDI or audio virtual cable. If you're already piping the signals to the top slot from an RS-232 keyboard, this is already happening, so the thing to solve is interpretation of the incoming data. I suspect that an actual RS-232 keyboard may not be sending the same signals that would arrive from even the 'dumbest' terminals. Not that I've ever looked into this, so it might be easy for all I know..

Where the ORG-Link port relay might help is when you have a keyboard or other source of characters at some fixed Baud rate that doesn't match anything the Organiser uses, because ORG-Link can relay between two ports with different Baud rates. There's no flow control so it can't be expected to cope with bulk data but single characters will be ok.
Daren
Posts: 58
Joined: Tue Jan 03, 2023 10:03 pm

Re: I want to use rs232 keyboard in OPL

Post by Daren »

Martin wrote: Sun Mar 03, 2024 1:10 am
Also see page 64 of the republished (Comms Link Manual) where you will see that on an LZ/LZ64 you can save the data from the capture buffer to a data file, procedure or in your case Notepad file.

Keep us posted on how you get on.
Sincerely Martin
Ah I did read that but completely forgot about it, I might be able to use the capture buffer instead and just use my TRS80 Model 100 as the keyboard, thanks for the reminder!

I will let you know how I get on :)
Post Reply