Table of Contents

USB operations

newRPL provides full USB support between calculator and PC: the calculator acts as an HID device, therefore the procedure of first-time setup is minimal, practically non-existent is some cases. The language implements a number of commands to handle file transfer between calculator and PC, as well as firmware update, as easy as possible.

Connection

In case of disconnection the status bar will show [ Click to reconnect ] allowing a quick reconnection of the calculator.

On the models that support USB power, the battery indicator will turn gray when the USB cable is plugged, to indicate it's drawing power from the USB port.

Data Transfer

Once the communication channel is set up, to transfer an object to newRPL Desktop use the command USBSEND: if the transfer is successful, the object will appear on newRPL Desktop screen.

Since USBSEND returns 1 in case of success and 0 otherwise, this snippet of code is the preferred way to ensure that the object on level 1 is transferred.

« DO
    DUP
  UNTIL
    USBSEND
  END
  DROP
»

The receiving calculator will immediately XEQ'te the object after the transfer has completed provided no other program is currently in execution. In that case XEQ'tion will be postponed after the first program has terminated.

The following program puts the above concepts together into action.

« @@ Write a program that sends PONG back to us...
  « "PING"
    "PONG"
    DO
      DUP 
    UNTIL
      USBSEND
    END
    DROP 
  »
  
  @@ ...and send the program to the other side
  DO
    DUP 
  UNTIL
    USBSEND
  END
  DROP 
»

The command USBRECV is used to manually receive an object (avoiding to run it if it's a program): it accepts a time-out in seconds, after which the transfer is aborted. Alternatively, setting flag -47 will achieve the same effect. In any case, if there's data waiting to be received a RX indicator will be displayed in the status area; since transfer are not queued if there's an object waiting to be received, any other USBSEND command issued by the source calculator will fail.

When flag -47 is set an object can be received and automatically XEQ'ted using the USBAUTORCV command.

Backup and Restore

newRPL allows archiving and restoring of memory across the USB wire. Simply:

  1. run USBRESTORE on the receiving calculator: the command needs a time-out in seconds, so
    30 USBRESTORE

    will usually suffice;

  2. run USBARCHIVE on the source machine.

The backup format is totally compatible with SDARCHIVE/SDRESTORE but bear in mind that different platforms support different amounts of RAM: it's always possible to transfer backups across different platforms, provided they fit in the available RAM.

Platform RAM
HP39GS / HP39g+ 256 KiB
HP40GS 256 KiB
HP50g 512 KiB
Prime G1 32 MiB
newRPL Desktop 10 MiB

The above procedure will send the backup file to the other end of the wire. newRPL Desktop also provides options to directly execute USBARCHIVE on the remote calculator and save the file to disk, without affecting the simulated calculator, and also to open a file from disk, and run a USBRESTORE directly on the remote machine. This is useful to backup your connected calculator.

USB Operations

Command Purpose Example
USBSEND Send an object across USB wire « “CONNECTED!” » USBSEND
USBRECV Manually receive an object across USB wire 5 USBRECV
USBAUTORCV Manually receive an object across USB wire and XEQ'te it USBAUTORCV
USBARCHIVE Send a complete backup across USB wire USBARCHIVE
USBRESTORE Receive a backup across USB wire and restore it 30 USBRESTORE
USBSTATUS Display status of USB connection USBSTATUS
USBON Enable the USB driver USBON
USBOFF Disable the USB driver USBOFF