Saravanan666/pypi-org huggingface dataset:
Package: serialmfg
OverviewThis module provides a partial Python SDK for interacting with Serial's API.
If you need to perform actions not provided in the SDK, please reference theAPI documentation.
If neither the API nor the library provides you with the necessary tools, please contactSerial Support.
The latest version of the library can be downloadedhere.InstallationClone the repository from GitHub or install via pip:git clone https://https://github.com/serialmfg/serial-py.gitorpip install serialmfgDependenciesThis project requires the following dependencies:requestsExample UsageGet an API key from your Serial account or admin.(Optionally) Generate a station ID from process builder in the serial web app.Implement your script:importserialmfgasserialserial.set_station_id('YOUR_STATION_ID')serial.set_api_key('YOUR_API_KEY')# ----------- Component Instances ----------- ## Creating a component instancemy_component_instance=serial.ComponentInstances.create(identifier="ABC-1234",component_name="Component Name")# Getting a component instancemy_component_instance_2=serial.ComponentInstances.get(identifier="XYZ-5678")# Listing component instancesdefective_components=serial.ComponentInstances.list({"status":"DEFECTIVE"})# ----------- Process Entries ----------- ## Creating a process entrymy_process_entry=serial.ProcessEntries.create(process_id="process-id",component_instance_identifier="ABC-1234")# Adding data to a process entrymy_process_entry.add_text(dataset_name="Foo",value="bar")my_process_entry.add_number(dataset_name="Pi Approx",value=3.141,lsl=3.1,usl=3.2)my_process_entry.add_boolean(dataset_name="Pass Fail Criteria",value=True,expected_value=True)my_process_entry.add_file(dataset_name="Oven Temperatures",path="/Users/me/Downloads/oven-temp.csv",file_name="oven-temp-todays-date.csv")my_process_entry.add_image(dataset_name="Cat Pictures",path="/Users/me/Documents/my-cat.png",file_name="jerry.png")my_process_entry.add_link(dataset_name="Link Child 1",child_identifier="XYZ-5678")# Submitting a process entrymy_process_entry.submit(cycle_time=42,is_pass=False)#Optionally add cycle_time or process result override
Package: serial-module
serial_module:串行接口模块目录结构serial_modulebasemock_serial.py:  模拟通讯串行接口基类real_serial.py:  真实通讯串行接口基类serial_controller.py:  串行接口控制类, 控制是采用模拟接口还是真实接口以及串行接口通讯日志data_typehex_struct.py:  十六进制结构体exceptionconnection_exception.py:  连接异常(没有插上专用串行接口或通讯协议错误导致)not_connected_exception.py:  无连接异常(用户需要自动手动调用函数连接)probe_not_down_exception.py:  探头无下压异常respond_parse_exception.py:  单片机的返回数据解析异常(crc8校验失败/与通讯协议不对应)timeout_exception.py:  超时异常(多次尝试请求无回应)interfaceserial_interface.py:  串行接口类的通用接口,如有其它接口可放在这requirements.txt
Package: serialmsgpacketizer
Send & Receive MsgPacketizer packets over serial link.See alsohttps://gitlab.com/advian-oss/python-msgpacketizerDockerFor more controlled deployments and to get rid of “works on my computer” -syndrome, we always
make sure our software works under docker.It’s also a quick way to get started with a standard development environment.SSH agent forwardingWe needbuildkit:export DOCKER_BUILDKIT=1And also the exact way for forwarding agent to running instance is different on OSX:export DOCKER_SSHAGENT="-v /run/host-services/ssh-auth.sock:/run/host-services/ssh-auth.sock -e SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock"and Linux:export DOCKER_SSHAGENT="-v $SSH_AUTH_SOCK:$SSH_AUTH_SOCK -e SSH_AUTH_SOCK"Creating a development containerBuild image, create container and start it (switch the 51459 port to the port from src/serialmsgpacketizer/defaultconfig.py):docker build --ssh default --target devel_shell -t serialmsgpacketizer:devel_shell .
docker create --name serialmsgpacketizer_devel -p 51459:51459 -p 51460:51460 -v `pwd`":/app" -it -v /tmp:/tmp `echo $DOCKER_SSHAGENT` serialmsgpacketizer:devel_shell
docker start -i serialmsgpacketizer_develpre-commit considerationsIf working in Docker instead of native env you need to run the pre-commit checks in docker too:docker exec -i serialmsgpacketizer_devel /bin/bash -c "pre-commit install"
docker exec -i serialmsgpacketizer_devel /bin/bash -c "pre-commit run --all-files"You need to have the container running, see above. Or alternatively use the docker run syntax but using
the running container is faster:docker run -it --rm -v `pwd`":/app" serialmsgpacketizer:devel_shell -c "pre-commit run --all-files"Test suiteYou can use the devel shell to run py.test when doing development, for CI use
the “tox” target in the Dockerfile:docker build --ssh default --target tox -t serialmsgpacketizer:tox .
docker run -it --rm -v `pwd`":/app" `echo $DOCKER_SSHAGENT` serialmsgpacketizer:toxProduction dockerThere’s a “production” target as well for running the application (change the “51459” port and “myconfig.toml” for
config file):docker build --ssh default --target production -t serialmsgpacketizer:latest .
docker run -it --name serialmsgpacketizer -v myconfig.toml:/app/config.toml -p 51459:51459 -p 51460:51460 -it -v /tmp:/tmp `echo $DOCKER_SSHAGENT` serialmsgpacketizer:latestLocal DevelopmentTLDR:Create and activate a Python 3.7 virtualenv (assuming virtualenvwrapper):mkvirtualenv -p `which python3.7` my_virtualenvchange to a branch:git checkout -b my_branchinstall Poetry:https://python-poetry.org/docs/#installationInstall project deps and pre-commit hooks:poetry install
pre-commit install
pre-commit run --all-filesReady to go, try the following:serialmsgpacketizer --defaultconfig >config.toml
serialmsgpacketizer -vv config.tomlRemember to activate your virtualenv whenever working on the repo, this is needed
because pylint and mypy pre-commit hooks use the “system” python for now (because reasons).Running “pre-commit run –all-files” and “py.test -v” regularly during development and
especially before committing will save you some headache.
Package: serialroomba
SerialroombaSerialroomba is a package that aims to simplify the control of a Roomba over its serial port.It was tested on a Roomba 570.Similar packages already exist, some relatively old, some too "low-level".Part of the goal of this package was also to practice Python OOP.UsageTo install this package, you simply need topip install serialroombaHere is an example script:fromserialroomba.serialroombaimportSerialRoombafromserialroomba.controllersimportCleaningMode,Moderoomba=SerialRoomba("/dev/ttyS0")roomba.mode_controller.current_mode=Mode.SAFEroomba.cleaning_controller.side_brush_pwm=10roomba.mode_controller.current_mode=Mode.PASSIVEroomba.cleaning_controller.current_cleaning_mode=CleaningMode.SPOTNot implementedMotors (Opcode: 138)"This command lets you control the forward and backward motion of Roomba’s main brush, side brush,
and vacuum independently."Since the state and direction of all cleaning motors need to be sent in a single byte,
managing the last state of them becomes complicated.The same functionality can be achieved using:main_brush_pwmside_brush_pwmvacuum_pwmLEDs (Opcode: 139)"This command controls the LEDs common to all models of Roomba 500."Scheduling LEDs (Opcode: 162)"This command controls the state of the scheduling LEDs present on the Roomba 560 and 570."Digital LEDs Raw (Opcode: 163)"This command controls the four 7 segment displays on the Roomba 560 and 570."Digit LEDs ASCII (Opcode: 164)"This command controls the four 7 segment displays on the Roomba 560 and 570 using ASCII character codes."Buttons (Opcode: 165)"This command lets you push Roomba’s buttons. The buttons will automatically release after 1/6th of a
second."Song (Opcode: 140)"This command lets you specify up to four songs to the OI that you can play at a later time. Each song is
associated with a song number."Play (Opcode: 141)"This command lets you select a song to play from the songs added to Roomba using the Song command."
Package: serial-sniffer
Serial SnifferInstallationpipinstallserial-snifferUsageserial-sniffer[-b<baudrate>][--no-timestamp][--raw][-o<filename>]<PORT>required parameters:PORTIs the port you want to sniff - this parameter is requiredoptional parameters:-b <baudrate>baudrate for the port.default - 115200-o <filename>output to a file,<filename>is the path of the output file.default -sys.stdout.--rawflag for raw output.default - remove ascii ESC chars and some control ascii chars, also removing carriage return (\r).--no-timestampflag to prevent adding timestamp for each line.
Package: serialstruct
Installation$pipinstallserialstructMotivationWhen sending a structured binary packet over Serial, the only way (that I’m aware
of) to guarantee packet alignment with arbitrary data is to send a header that’s
larger than any of the elements and add padding between each element. Here’s an
example:structPacket{intsensor1;intsensor2;}If we send this over the wire and start reading at an arbitrary time, it’s
impossible to know what byte of the packet we’re reading. To mitigate this we can
add a header and some padding.structPacket{charheader[5];// Any sequence without a '\0'intsensor1;charpad1;// '\0'intsensor2;charpad2;// '\0'}Now we just need to wait until the header sequence is read and we can consume the
rest of the packet without worrying about alignment.pySerial only implements a FramedPacket which expects a unicode sequence that
starts with a ‘(’ (0x28) and ends with a ‘)’ (0x29). This means the bytes 0x28 and
0x29 cannot appear anywhere in the binary data.UsageSubclassserialstruct.StructuredPacketto specify the data size in the packet
and to implement thehandle_packet()callback function.importstructimportserialimportserialstructimporttimePACKET_STRUCT=struct.Struct("<IxIx")classMyPacket(serialstruct.StructuredPacket):DATA_SIZE=10# Excluding header: 4+1+4+1def__init__(self):super(MyPacket,self).__init__(self.DATA_SIZE)defhandle_packet(self,packet):print(PACKET_STRUCT.unpack(packet))defsend_packet(self,packet):self.transport.write(self.HEADER)self.transport.write(packet)ser=serial.serial_for_url("loop://",baudrate=115200,timeout=1)withserial.threaded.ReaderThread(ser,MyPacket)asprotocol:# unsigned int, pad, unsigned int, pad; with no alignmentpacket=PACKET_STRUCT.pack(1,2)protocol.send_packet(packet)time.sleep(1)Prints:(1,2)
Package: serial-uploader
# Serial UploaderSimple script to upload switch configurations though a serial connection.Just have the configuration that you want to upload in a file, and run:sudo serial_uploader \
    --config-file my_switch_config.txt -
    --serial-device-path /dev/ttyUSB0If you need user and password, you can pass the username, and the password
will be prompted for:sudo serial_uploader \
    --config-file my_switch_config.txt \
    --serial-device-path /dev/ttyUSB0 \
    --user myuser
Package: serial-visualisation
serial-visualisationFor simple visualisation of serial input (e.g. from an Arduino or similar device).Version: 1.2.0Author: ES AlexanderRelease Date: 12/Dec/2019You need to know:Allows the reading of serial input to a computer, and display of it in a grid as an image. The displayed grid can be optionally blurred for sub-pixel resolution, and can also be formatted with a fully-customisable RGB or greyscale colourmap. The displayed grid can be saved to a constant-framerate video.Each set of serial values should be separated by a newline character ('\n'), and values within a set should be tab-separated ('\t').To run:download and install Python 3 if not already installed (select add to PATH)windows users: open command prompt (e.g. press windows key, type cmd, press enter), Mac users: open terminaltypepip install --upgrade serial-visualisation(only have to do this once at the start of your session, and probably only once per computer) - this step may cause issues if python and/or pip are not in your PATH. Google 'add pip to path' for a solution. Users with multiple Python installs may need to usepip3instead ofpip.make sure your Arduino software on the computer isn't using the serial port (only one program can access it at once, so program the Arduino normally, and then just don't open the serial plotter or monitor, and run this instead)run usingpython -m serial_grid.serial_grid(orpython3with multiple Python installs)answer the questions, and optionally save your settingswait for it to start displaying (takes a few seconds it seems)click the Data window and press 'q' or 'Q' or Escape to quit, or press 'p' (play/pause), 'c' (continue), or 's' (start/stop) to pause and/or resume the display (they're all the same, just pick your preferred key).I hope this works well for your project! If there are any problems, or suggestions for improvement, please submit an Issue on the github page (https://github.com/ES-Alexander/serial-visualisation/issues).
Package: serial-weighing-scale
Serial Weighing ScaleArduino-based cheap precision weighing scale for readout via serial communication.Precision weighing scales that include serial port communication usually come at considerable cost. This project showcases an affordable alternative.
Using readily available electronics parts, the scale's measurements can be read via serial communication by a simple Python class.Note:The design could easily be extended with an Arduino display to show the measurements.Bill of MaterialsArduino Uno (including USB-A to USB-B cable)Load cell amplifier HX711 (Sparkfun), e.g. from mouser.co.uk: 474-SEN-13879Load cell (100g and 500g cells used), e.g. from mouser.co.uk: 474-SEN-14727 or 474-SEN-14728Jumper wires, pin headers, nylon spacers for electronicsAcrylic or other material of choice for case and load cell mountHX711 arduino library fromolkal/HX711_ADCBuildLoad .ino onto ArduinoAssemble electronics, e.g. as described in thisHX711 wiring tutorialPrint 3D components fromdrawings(Drawings namedmodelare only for design, no need to print these)Move electronics into caseCalibrate scale via Arduino IDE serial monitor commands. See below for communication protocol for calibration.UsageConnect scale via USB to machine that is going to read the measurements from the scaleInteract via pythonSerialScaleobject:Open connection withSerialWeighingScaleobject & perform standard operations on itimportnumpyasnpimporttimefromserial_weighing_scaleimportSerialWeighingScaleserial_port="/dev/ttyACM0"# for Unix systems. "COM1" on Windows systemsscale=SerialWeighingScale(port=serial_port)whilenotscale.scale_is_ready():time.sleep(.1)# Perform standard operationsscale.tare_scale()# Tare scalescale.read_weight()# Take single measurementscale.read_weight_repeated(n_readings=5)# Get n readingsscale.read_weight_reliable(n_readings=5,measure=np.mean)# Get statistic of n readingsOpen connection by testing specific serial ports sequentiallyimporttimefromserial_weighing_scaleimportconnect_serial_scalescale=connect_serial_scale(test_ports=["/dev/ttyACM0","/dev/ttyACM1"])whilenotscale.scale_is_ready():time.sleep(.1)Not yet implemented: Calibrate scale via pythonimporttimefromserial_weighing_scaleimportconnect_serial_scalescale=connect_serial_scale(test_ports=["/dev/ttyACM0","/dev/ttyACM1"])whilenotscale.scale_is_ready():time.sleep(.1)known_mass=45.05# weight [gram] of object used for claibrationscale.calibrate(known_mass=known_mass)Communication protocol for messages between python and ArduinoTare scale: send "t" -> Tare scale & Arduino confirms with "t"Read scale: send "w" -> Arduino returns latest readingCalibrate scale: send "c" + weight of known massArduino confirms by sending known mass value backSend "a" once known mass was placed on scale -> Arduino performs calibration & returns new calibration factor that needs to be added toserial_scale.inoTODOAdd calibration routine to .ino & .pyAdd test curve to .pyContributorsCode & electronics by Lars Rollik.
Scale 3D printing drawings by Simon Townsend (Advanced Manufacturing FabLabs, Sainsbury Wellcome Centre).
Thanks to Benjamin Hahl for useful input on the design.
Package: serialXfer
License:BSDGoals:Add YModem - Original goal, Mostly doneAdd YModem Batch - WIPAdd Zmodem - PlanningAdd Kermit - Don’t wait up….Make threaded - WIPComplete rewrite - PerhapsChanges:0.3  Original Release, based on xmodem 0.2.4 from PyPi (http://pypi.python.org/pypi/xmodem)Known Bugs:More than I care to list - use with caution!Credit:All credit to the original author, Wijnand ModdermanUsage:TODODependencies:None that I know of
Package: serial-y-cable
The serial_y_cable ToolUsagebasic usage of serial_y_cable:

  ┌─────────────────┐                                                                     ┌────────────────────────────────┐
  │ hardware / DUT  ├──  hardware serial dev   ─────┬───────  virtual serial dev 0  ──────┤ application that controls      │
  └─────────────────┘      e.g.://dev/ttyUSB0       │          /tmp/ttyUSB0-V0            │ the hardware / DUT             │
                                                    │                                     └────────────────────────────────┘
                                                    │
                                                    │                                     ┌────────────────────────────────┐
                                                    └───────  virtual serial dev 1  ──────┤ serial terminal for monitoring │
                                                                /tmp/ttyUSB0-V0           │  - e.g. minicom, screen, etc.  │
                                                                                          └────────────────────────────────┘LimitationsFor now only monitoring on both virtual devices is implemented (bytes are only copied from the hardware side to the virtual devices).RequirementsThe following modules are needed forserial_y_cablepyserialkey_strokeYou can install them easily from pypi.org:pip install pyserial key_strokeThe closing word for this week:Have fun with the serial_y_cable tool!Thomas@chriesibaum.com
Package: serialzy
serialzySerialzy is a library for python objects serialization into portable and interoperable data formats (if possible).ExampleSuppose you have a catboost model:fromcatboostimportCatBoostClassifiermodel=CatBoostClassifier()model.fit(...)Firstly you should find a proper serializer for the catboost model type or the corresponding data format:fromserialzy.registryimportDefaultSerializerRegistryregistry=DefaultSerializerRegistry()serializer=registry.find_serializer_by_type(type(model))# registry.find_serializer_by_data_format("cbm")Serializers have several properties:serializer.available()# can be used in the current environmentserializer.requirements()# libraries needed to be installed to use this serializerserializer.stable()# has portable data formatSerializers can provide data format and schema for a type:serializer.data_format()serializer.schema(type(model))Serialization:withopen('model.cbm','wb')asfile:serializer.serialize(model,file)Deserialization:withopen('result','rb')asfile:deserialized_obj=serializer.deserialize(file)List of supported libraries for stable serialization:LibraryTypesData formatPython std libint, str, float, bool, Nonestring representationPython std libList, Tuplecustom formatCatBoostCatBoostRegressor,CatBoostClassifier,CatBoostRankercbmCatBoostPoolquantized poolTensorflow.KerasSequential,Modelwith subclassestf_kerasTensorflowCheckpoint,Modulewith subclassestf_pureLightGBMLGBMClassifier,LGBMRegressor,LGBMRankerlgbmXGBoostXGBClassifier,XGBRegressor,XGBRankerxgbTorchModulewith subclassesptONNXModelProtoonnx
Package: seriarduino
SeriArduinoInstallFor ArduinoClone the repoCompress theseriarduino_cppfolder intoseriarduino_cpp.zipNote: You can also downloadseriarduino_cpp.zipfrom the releasesOpen the Arduino IDEGo intoSketch>Include a libraryand add the library from theseriarduino_cpp.zipfileFor Python (tested on Raspbian)Clone the repo OR uncompress theseriarduino_py.zipfile from the releasesOpen theseriarduino_pyfolder in a terminalIn the terminal, enter./setup.py installUsageThe following sample is linking an Arduino with a Raspberry Pi:Arduino side#include<SeriArduino.h>SeriArduinoraspberry;Stringinput;floatvalue;voidsetup(){// We set the serial to 9600 bauds (be sure to use the same on the Python side)Serial.begin(9600);}voidloop(){// If raspberry gets any dataif(raspberry.available()){// We read the data and save it into the "input" variableinput=raspberry.read();// We convert the input into a float,// to do some computations latervalue=input.toFloat();Serial.println("We got a "+String(value));// A simple computationvalue=value*2;// We send the new data to the Raspberry Piraspberry.write(value);}delay(100);}Python side (Raspberry Pi)fromseriarduinoimportSeriArduinoarduino=SeriArduino(bauds=9600)whileTrue:# We ask what value to sendval=input("Value to send: ")# We send to Arduino this valuearduino.write(val)print("Value sent: ",val)# We wait for the answeranswer=arduino.read()print("The Arduino answer is: ",answer)By default, SeriArduino will try to find the serial address, but you can also manually specify it by using the address argument on the constructor (e.g.SeriArduino(address = "/dev/ttyACM0"))
Package: seriate
seriateOptimal ordering of elements in a set given their distance matrix.Overview•How To Use•Contributions•LicenseOverviewThis is a Python implementation ofSeriationalgorithm. Seriation is an approach for ordering elements in a set so that the
sum of the sequential pairwise distances is minimal. We state this task
as a Travelling Salesman Problem (TSP) and leverage the powerfulGoogle's or-toolsto do heavy-lifting. Since TSP is NP-hard, it is not possible to calculate
the precise solution for a big number of elements. However, the or-tools'
heuristics work very well in practice, and they are used in e.g. Google Maps.Anynumpy.roll-edresult is equivalent.How To Useimportnumpyfromscipy.spatial.distanceimportpdistfromseriateimportseriateelements=numpy.array([[3,3,3],[5,5,5],[4,4,4],[2,2,2],[1,1,1]])print(seriate(pdist(elements)))# Output: [4, 3, 0, 2, 1]The example above shows how we order 5 elements:[3, 3, 3],[5, 5, 5],[4, 4, 4],[2, 2, 2]and[1, 1, 1]. The result
is expected:[1, 1, 1][2, 2, 2][3, 3, 3][4, 4, 4][5, 5, 5]pdistfromscipy.spatial.distanceuses Euclidean (L2) dstance metric by default, so the distance between[x, x, x]and[x + 1, x + 1, x + 1]is constant: √3. Any other distance
is bigger, so the optimal ordering is to list our elements in the increasing
norm order.ContributionsContributions are very welcome and desired! Please follow thecode of conductand read thecontribution guidelines.LicenseApache-2.0, seeLICENSE.md.