Screenshot (PX-41CX)
Table of Contents
This Script was created in collaboration with Pierre Houbert.
Introduction #
The PX-41CX allows the user to backup the memory contend using the enclosed USB serial connection cable. For details I suggest you download the PX-41CX documentation from Pierre Houbert’s hompage. The documentation describes how to receive scree shots manually using CoolTerm.
However you might want to automate the process so no copy/paste from a terminal window is needed. Just like with the Dump this can be archived with Python’s pyserial package.
The Script will read the screen shots and convert them directly to bitmap files.
Preparation #
You need to install Python 3 if you have not done so already as well as the pyserial
package and the PX-41CX Hex to
Bmp tool. Easiest way to get them is to use git to clone them into the directory containing Screenshots.py
macOS #
On macOS you can use the following commands.
brew install \
"coolterm" \
"python3"
pip3 install --break-system-packages \
"intelhex" \
"microbmp" \
"pyserial"
git clone https://github.com/diemheych/px41cx-hex2bmp.git
Windows & Linux #
Windows installation is described in Pierre Houbert’s document and for Linux you use the package manager of your distribution.
Using git clone #
Alternatively you can clone git clone Calculator-Scripts project with it’s sub modules which will set up everything with correct directory structure:
git clone https://git.code.sf.net/p/calculator-scripts/code calculator-scripts
cd calculator-scripts
git checkout --track master
git submodule init
git submodule update
Utilities/Install.command
cd PX-41CX/Dump
Usage #
Screenshots.py is meant to be used with the executable flag set. It takes the file name Prefix to store the screeschot
- Set the environment variables
USB_Serial_Device
andUSB_Serial_Speed
. - Start Screenshots.py
- Use the calculators
MENU
⇒SHIFT
to make one or more screen shots - Press
Ctrl-C
to end the program.
macOS & Linux #
export USB_Serial_Device=/dev/tty.usbserial-14440
export USB_Serial_Speed=115200
Screenshots.py Image
For screen shots use «MENU» ⇒ «SHIFT» on the PX-41CX
Press `Ctrl-C` to end the program.
Image00.bmp
Image01.bmp
Image02.bmp
Image03.bmp
^CTraceback (most recent call last):
File "/Users/Shared/Work/Projects/Calculator-Scripts/PX-41CX/Dump/Screenshots.py", line 58, in <module>
Line_Array = Device.readline ()
^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/serial/serialposix.py", line 565, in read
ready, _, _ = select.select([self.fd, self.pipe_abort_read_r], [], [], timeout.time_left())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt
Windows #
SET USB_Serial_Device=COM8:
SET USB_Serial_Speed=115200
python Screenshots.py Image
For screen shots use «MENU» ⇒ «SHIFT» on the PX-41CX
Press `Ctrl-C` to end the program.
Image00.bmp
Image01.bmp
Image02.bmp
Image03.bmp
^CTraceback (most recent call last):
File "/Users/Shared/Work/Projects/Calculator-Scripts/PX-41CX/Dump/Screenshots.py", line 58, in <module>
Line_Array = Device.readline ()
^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/serial/serialposix.py", line 565, in read
ready, _, _ = select.select([self.fd, self.pipe_abort_read_r], [], [], timeout.time_left())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt
Source #
#!env python3
import os
import serial
import sys
sys.path.append("px41cx-hex2bmp")
from px41cx_hex2bmp import create_bmp
# Set connection data from environment variables.
#
USB_Serial_Device = os.getenv ('USB_Serial_Device')
USB_Serial_Speed = os.getenv ('USB_Serial_Speed')
Output_Array = bytearray ()
# The script takes a single parameter from the command line which is the
# beginning of the file names genearated. If no file name is given "Image" is
# used
#
if len (sys.argv) > 1:
Output_File = sys.argv[1]
else:
Output_File = "Image"
# end if
print ("""
For screen shots use «MENU» ⇒ «SHIFT» on the PX-41CX
Press `Ctrl-C` to end the program.
""")
# open serial port
#
with serial.Serial (USB_Serial_Device, USB_Serial_Speed, timeout=1) as Device:
Count = 0
while True:
# Read one line from serial port. The result is a byte array.
#
Line_Array = Device.readline ()
# if a line is ending on „DISP“ is received then the next line containts
# the screen shot data to be converted to a bitmap. All other lines are
# ingored.
#
if Line_Array.endswith(b'DISP\n') :
Line_Array = Device.readline ()
create_bmp (Output_File, Line_Array, Count)
Count = Count + 1
# end if
# end while
# end with