From jodell@hpcupt1.HP.COM Fri Jul 13 09:09:01 1990 From: jodell@hpcupt1.HP.COM (Jamie Odell) Newsgroups: comp.sys.handhelds Subject: Power of 48 from your PC Date: 11 Jul 90 01:01:46 GMT Organization: Hewlett Packard, Cupertino Several people have mentioned the lack of support for "Using the Power of Your HP-48sx from your PC" in the cable/software package. In order to help bridge that gap - and mostly because I can't type long programs on the 48's keyboard - I have written a program that allows object entry from a terminal or terminal emulator. This program works, but it is far from complete. I wrote it basically to see if I could do it. I hope that someone can get some good use out of it. Purpose: This program will allow a user to type objects on a terminal (or terminal emulator directly to the HP-48sx. Directions for use: Download the directory TERM. Setup your IOPAR variable for XON XOFF and for whatever other communication parameters you want to use. For example: for 9600 baud, no parity checking, and XON XOFF - your IOPAR variable could be { 9600 0 1 1 3 1 }. Note that the translate code, and checksum type are not used. Connect the 48sx to your terminal or PC and set up the communication parameters on both the 48 and PC. Make TERM the current directory, and execute TRM. You should see: Term Entry 1.0 on your terminal screen, as well as on the 48sx screen. Now you can type things on your terminal. Each character is sent to the 48. To tell the 48 that you are finished with the current object, type END on a line by itself. All the lines you have typed so far will be combined into an object and left on the stack. The backspace key (Control-H) will delete the last character you typed on a current line. This is the only form of editing allowed. To enter the symbols "<<", ">>", or "->" you should type \<<, \>>, \-> respectively. The program automatically takes care of converting the symbols. Since this program uses XMIT and SRECV for I/O, the translate code in IOPAR is not used. This means that \<<, \>>, and \-> will be the only symbols converted. Please note that this is the 1.0 version of this program. I wrote it quickly because I wanted to be able to use a typewriter keyboard to enter data into the 48. I have some ideas for enhancements such as better editing capabilities, two way data transfer, more control of the 48 from a terminal, etc. If I get the chance, I'll add some of these features. Also, and this is VERY IMPORTANT. This code expects the stack to be empty before it is run. I know this is not good calculator programming etiquette, but hey, I'll fix it in a later release. As you've probably guessed, I'm a software engineer :-) Feel free to do whatever you want to this code. Please let me know if you make any cool enhancements. The directory contains the following objects: TRM - Main entry point to this program. This saves the current flags, prints "Term Entry 1.0" on the 48's display, and calls GETPROG. Flag 2 is set. Flag 2 does not mean anything. It was supposed to mean that the program should echo characters back to the terminal. The program always echos characters to the terminal, so flag 2 doesn't do anything. I should remove it, but I haven't yet. GETPROG - Get a program (or any object). This procedure opens I/O communications, clears the I/O buffer, and sends "Term Entry 1.0" to the Terminal. Then it collects lines of text, until the user types "END". Afterwards, it combines all the lines of text into a single object and leaves it on the stack. READLN - Reads a line of text. A line is a string of characters terminated with a carriage return. FIXLN - Convert \<<, \>>, \-> into their 48sx representations everywhere they appear in a line. CNVR - Convert all the strings on the stack (lines) into one object. READCH - Read a single character from the terminal, and add it to the current string. If the character is a backspace, then erase one character from the string. If the character is a carriage return, then echo a carriage return, line feed sequence. DECL - Remove one character from the current line. LIN - Current line is stored here. When the line is terminated, it gets pushed as a string onto the stack. Jamie Odell MXO - Commercial Systems Division (CSY) Hewlett-Packard Co. jodell@hpda.hp.com ------------------------------------------------------------------------------ #FD90h 953 %%HP: T(3)A(D)F(.); DIR TRM \<< CLLCD "Term Entry 1.0" 1 DISP RCLF \-> f \<< 2 SF @ Set terminal echo on (not used!). GETPROG f STOF \>> \>> GETPROG \<< OPENIO BUFLEN DROP SRECV DROP @ Clear the serial I/O buffer before doing anything DROP "Term Entry 1.0" 13 CHR + 10 CHR + XMIT @ Transmit message with CR/LF DROP DO READLN LIN @ Read in next line FIXLN @ Convert special characters to 48 characters UNTIL LIN "END" 13 CHR + SAME @ Loop until user types END on a line by itself "" 'LIN' STO END CNVRT @ Pack all lines into a single object \>> READLN \<< DO READCH DUP @ Read characters until CR 'LIN' SWAP STO+ UNTIL 13 CHR SAME LIN 2 DISP END \>> FIXLN \<< \-> l \<< 1 CF @ Check for occurences of \<< \>> \-> DO l CASE l @ Loop until no more occurences are found, "\\<<" POS @ converting each occurence on the way to the 48 THEN l @ representation. "\\<<" POS "\<< " @ REPL @ More special characters can be added as needed. END l @ Just add a new case. "\\>>" POS @ Remember to replace the number of characters you THEN l @ remove with an identical number of characters. "\\>>" POS " \>>" REPL END l "\\->" POS THEN l "\\->" POS "\-> " REPL END 1 SF END 'l' STO UNTIL 1 FS? @ Flag 1 is a boolean used to tell us if we are done END l \>> \>> CNVRT \<< DROP "" DEPTH @ Drop the "END" string off the stack \-> d \<< IF d 1 > @ Combine everything on the stack into one string THEN 2 d START + NEXT END OBJ\-> @ Convert the string into an object \>> \>> READCH \<< DO @ Wait until the user types a key on the terminal UNTIL BUFLEN DROP 0 > END 1 SRECV @ Get one character at a time! DROP \-> c \<< CASE c 13 @ If the character is a return then echo CR/LF CHR SAME THEN c 10 CHR + XMIT DROP c END c 8 @ If the character is a backspace, then erase the CHR SAME @ character from the terminal, and remove it from THEN c @ the current line. " " + c + XMIT DROP DECLN "" END c XMIT DROP c @ Otherwise, just echo the character. END \>> \>> DECLN \<< LIN 1 LIN SIZE 1 - SUB 'LIN' STO \>> LIN "" END