SartoriUSB
USB serial connection to Sartorius Quintix Scales
Example:
import sartoriusb as sub
with sub.SartoriusUsb('COM4') as conn:
result = conn.measure()
assert result.mode == "G"
assert result.value == "+3.4"
assert result.unit == "mg"
assert result.stable == True
assert result.message == None
Required settings on the scale
The USB protocol on the scale must be set to SBI.
Connection to the scale
The prefered way to establish an connection is the use of a context manager:
with sartoriusb.SartoriusUsb('COM4') as conn:
For manually handling the connection, the methods connect() and
close() can be used. For convenience there is also and open()
method that just behaves like connect()
Sending commands and receiving output
Sending commands to the scale can be done with the send(cmd), the
available commands according to the manual are listed below, but you could
but propably shouldn't send any arbitrary commands to the scale.
For reading the results from the scale, there are two methods available:
read(bytes): reads a number of bytes from the scalereadlines(): returns a list of text lines, already decoded from bytes
Since sending a command and recieving an output are often used side by side,
there is a convenience method: get(cmd) will first send the command and
returns the output from the scale as a list of strings.
Measuring
To measure a weight (or whatever the scale is set to), you could use
get(CMD_PRINT) and parse the output yourselve or use the measure()
method and get an already parsed output:
The function returns a sartoriusb.Measurement named tuple:
Measurement.mode: The measurement mode, might beunknownif reporting on the scale is set to 16 byte outputMeasurement.value: The value as string as reported by the scale; whitespace an nonnumeric characters are removed, soint()orfloat()could be used directlyMeasurement.unit: The unit of the Measurement reported by the scale. Might beNoneif it was an unstable readMeasurement.stable: Boolean value indicating if the measured value was stable or unstableMeasurement.message: If a non-measurement message was sent from the scale, it is reported here and all other fields are set toNone. For a regular measurement result this field isNone.
Available Commands
-
CMD_PRINT: "Print" the current measurement result -
CMD_TARA: performa a tara or set the display to zero -
CMD_EXPCLICIT_TARA: explicit tara only -
CMD_EXPCLICIT_NULL: explicit set display to zero -
CMD_INFO_TYPE: show scale type -
CMD_INFO_SNR: show serial number of scale -
CMD_INFO_VERSION_SCALE: show software version of the scale -
CMD_INFO_VERSION_CONTROL_UNIT: show the software version of the command and display module -
CMD_INFO_USER: display user and device id -
CMD_FILTER_ENVIRONMENT_VERY_STABLE: set the filter to "very stable enviroment" -
CMD_FILTER_ENVIRONMENT_STABLE: set the filter to "stable enviroment" -
CMD_FILTER_ENVIRONMENT_UNSTABLE: set the filter to "unstable enviroment" -
CMD_FILTER_ENVIRONMENT_VERAY_UNSTABLE: set the filter to "very unstable enviroment" -
CMD_KEYBOARD_LOCK: lock the keyboard on the command and display module -
CMD_KEYBOARD_UNKLOCK: unlock the keyboard on the command and display module -
CMD_KEYPRESS_PRINT: simulate a keypress on the command modules 'print' key -
CMD_KEYPRESS_CANCEL: simulate a keypress on the command modules 'cancel' key -
CMD_BEEP: make the scale beep -
CMD_ADJUST_INTERNAL: start internal adjustment -
CMD_ADJUST_EXTERNAL: start external adjustment with standard weights -
CMD_RESTART: restart the scale
Development
To install the development version of SartoriUSB:
git clone https://github.com/holgi/sartoriusb.git
cd sartoriusb
# intialize the developement environment and activate it
make devenv
.venv/bin/activate
To run the tests, run make tests or make coverage for a complete report.
Metadata
Release files for SartoriUSB 0.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| SartoriUSB-0.2.5.tar.gz | 8.5 kB | Without provenance | Details for SartoriUSB-0.2.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| SartoriUSB-0.2.5-py3-none-any.whl | Python 3 | none | any | Details for SartoriUSB-0.2.5-py3-none-any.whl |
Total release size: 18.1 kB
Release files / SartoriUSB-0.2.5.tar.gz
| Download URL | SartoriUSB-0.2.5.tar.gz |
|---|---|
| Size | 8.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4fbc35e3d05df804b742bef4d3025d06f9717c1c6919686968b748e276e5c0fc
|
|
BLAKE2b-256 checksum How to use checksums |
d1e0caf7a2d8697e9074b563d47d326f6e95fa13cb10a528abd63cb49c1e7966
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.22.0
|
Release files / SartoriUSB-0.2.5-py3-none-any.whl
| Download URL | SartoriUSB-0.2.5-py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4474a4e033fb3e2093e46575d9e7362f786e6bf36cba04dcbfb4091cd3730e8d
|
|
BLAKE2b-256 checksum How to use checksums |
a7959bfef0856a3581b3d37785958d4de874445058fcad696dfa98f06528877f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.22.0
|
Security for SartoriUSB 0.2.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.