{"id":15172895,"url":"https://github.com/asukhanov/liteserver","last_synced_at":"2025-10-26T04:30:53.574Z","repository":{"id":57438756,"uuid":"163345542","full_name":"ASukhanov/liteServer","owner":"ASukhanov","description":"Lightweight Process Variable Server","archived":false,"fork":false,"pushed_at":"2024-10-28T01:58:33.000Z","size":791,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-31T14:22:05.975Z","etag":null,"topics":["ads1115","apstrim","hmc5883","i2c-sensors","instruments","labjack","mmc5983","qmc5883","raspberry-pi","remote","sensors","server","usb-camera"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ASukhanov.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-27T23:47:30.000Z","updated_at":"2024-10-28T01:58:37.000Z","dependencies_parsed_at":"2024-08-12T05:46:40.399Z","dependency_job_id":"c1b5cc16-a88c-4826-bc82-ac7d0be354e4","html_url":"https://github.com/ASukhanov/liteServer","commit_stats":{"total_commits":243,"total_committers":1,"mean_commits":243.0,"dds":0.0,"last_synced_commit":"c6e05accae869ef71f8ba6a4983eb04a502b1114"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ASukhanov%2FliteServer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ASukhanov%2FliteServer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ASukhanov%2FliteServer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ASukhanov%2FliteServer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ASukhanov","download_url":"https://codeload.github.com/ASukhanov/liteServer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238258991,"owners_count":19442511,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ads1115","apstrim","hmc5883","i2c-sensors","instruments","labjack","mmc5983","qmc5883","raspberry-pi","remote","sensors","server","usb-camera"],"created_at":"2024-09-27T10:22:52.221Z","updated_at":"2025-10-26T04:30:53.126Z","avatar_url":"https://github.com/ASukhanov.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# liteserver 3.1.0\nVery Lightweight Data Object Server. \nIt hosts Lite Data Objects (**LDO**, analog of Process Variables in \nEPICS) and provides info/set/get/read/subscribe remote access to them using \nUDP protocol. Data encoding is implemented using **CBOR** specification, \nwhich makes it very fast and efficient.\n\n### Data logging and retrieving\nData objects can be logged and retrieved using an **apstrim** package (https://pypi.org/project/apstrim).\n\n### Features\n - Simplicity. The network protocol is **UDP**, error correction of \nlate/missing/mangled data is implemented. Binary serialization protocol **CBOR**. \nProgramming interface is very similar to JSON.\n - Low latency, connection-less.\n - Supported requests:\n   - **info()**, returns dictionary with information on requested LDOs and \n   parameters\n   - **get()**, returns dictionary of values of requested LDOs and parameters\n   - **read()**, returns dictionary of changed readable (non-constant) \n   parameters of requested LDOs\n   - **set()**, set values or attributes of requested LDO parameters\n   - **subscribe(callback)**, subscribe to a set of the objects, if any object \nof the requested LDOs have been changed, the server will publish the changed \nobjects to client and the callback function on the client will be invoked.\n - Multidimensional data (numpy arrays) are supported.\n - Access control info (username, program name) supplied in every request\n - Name service\n   - file-based\n   - network-based using a dedicated liteServer  (not commissioned yet)\n - Basic spreadsheet-based GUI: **pypeto**\n - Architectures. All programs are 100% python. Tested on Linux and partially on Windows.\n - Companion applications:\n   - [liteAccess: Access to liteServer's](https://pypi.org/project/liteaccess)\n   - [pvplot: Dynamic plotting tool](https://pypi.org/project/pvplot)\n   - [apstrim: Data Logger](https://pypi.org/project/apstrim)\n   - [Imagin: Image analysis](https://github.com/ASukhanov/Imagin) \n\n### Supported devices\nServer implementations for various devices are located in .device sub-package. \nA device server can be started using following command:\u003cbr\u003e\n    python3 -m liteserv.device.\u003cdeviceName\u003e \u003cArguments\u003e\n\n- **device.litePeakSimulator**: Waveform simulator with multiple peaks and a background noise.\n- **device.liteScaler**: Test implementation of the liteServer, \nsupporting 1000 of up/down counters as well as multi-dimensional arrays.\n- **device.senstation**: Server for various devices, connected to Raspberry Pi\nGPIOs: 1-wire temperature sensor, Pulse Counter, Fire alarm and Spark detector,\nBuzzer, RGB LED indicator, OmegaBus serial sensors. \nVarious I2C devices: ADC: ADS1x15, Magnetometers: MMC5983MA, HMC5883, QMC5983, \nTLV493D.\nI2C multiplexing using TCA9548 or PCA9546.\nNUCLEO-STM33 mixed signal MCU boards, connected to Raspberry Pi over USB.\n- **device.liteGQ**: Geiger Counter and a gyro sensor GMC-500 from GQ Electronics.\n- **device.liteWLM**: Wavelength Meter WS6-600 from HighFinesse.\n- **device.liteLabjack**: LabJack U3 analog and digital IO module.\n- **device.liteUSBCam**: Server for USB cameras.\n- **device.liteUvcCam**: Server for USB cameras using UVC library.\n- **device.liteVGM**: (Obsolete) Server for multiple gaussmeters from AlphaLab Inc.\n\n## Installation\n\n### Dependencies:\n- Python3 3.6 or higher.\n- [CBOR2](https://pypi.org/project/cbor2/)\n\n### Installation:\u003cbr\u003e\n```python3 -m pip install liteserver```\n\nAdditional libraries may be required for specific devices.\n\n## Examples\nMost convenient way to test a base class functionality is by using **ipython3**, \n\n#### Test server: liteScaler\nStart liteScaler on a local host:\u003cbr\u003e\n```python -m liteserver.device.liteScaler -ilo```\u003cbr\u003e\nTo monitor, use:\u003cbr\u003e\n```python -m pvplot L:localhost:dev1:counters```\n\n#### Peak simulator\n```python -m liteserver.device.litePeakSimulator -ilo```\u003cbr\u003e\nTo monitor, use:\u003cbr\u003e\n```python -m pvplot -s.01 -a'L:localhost:dev1' 'x,y'```\n\n#### Labjack U3-HV\n```python -m liteserver.device.liteLabjack -ilo```\u003cbr\u003e\nTo monitor, use:\u003cbr\u003e\n```python -m pvplot -a'L:localhost:dev1' 'tempU3 ADC_HV[0] ADC_HV[1] ADC_HV[2] ADC_HV[3] ADC_LV'```\n\n### Server for all supported peripherals: senstation:\n#### I2C Support\nTo detect available devices on the multiplexed I2C chain:\u003cbr\u003e\n```python -m utils.i2cmux -M 112```\u003cbr\u003e\nIf multiplexer address on your board is not 112, you can find it using:\u003cbr\u003e\n```i2cdetect -y 1```\n\n#### Start the senstation server\nStart the senstation server through default network interface:\u003cbr\u003e\n```python -m liteserver.device.senstation```\n\n#### Interfacing to senstation using python\n```python\nfrom liteserver import liteAccess as LA \nfrom pprint import pprint\n\nHost = 'localhost'\nLAserver = Host+':server'\nLAdev1   = Host+':dev1'\nLAdev2   = Host+':dev2'\n\n#``````````````````Programmatic way, using Access`````````````````````````````\nLA.Access.info((Host+':*','*'))# map of all devices and parameters the Host\nLA.Access.info((LAserver,'*'))\nLA.Access.get((LAserver,'*'))\nLA.Access.set((LAdev1,'frequency',2.0))\nLA.Access.subscribe(LA.testCallback,(LAdev1,'cycle'))\nLA.Access.unsubscribe()\n#,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\t\n#``````````````````Object-oriented way````````````````````````````````````````\n# Advantage: The previuosly created PVs are reused.\nallServerParameters = LA.PVs((LAserver,'*'))\npprint(allServerParameters.info())\npprint(allServerParameters.get())# get all parameters from device LAserver\n# get all readable parameters from device Scaler1:server, which have been \n# modified since the last read:\npprint(allServerParameters.read())\n\nallDev1Parameters = LA.PVs((LAdev1,'*'))\nprint(allDev1Parameters.info())\n\nserver_performance = LA.PVs((LAserver,'perf'))\npprint(server_performance.info())\npprint(server_performance.get())\n# simplified get: returns (value,timestamp) of a parameter 'perf' \npprint(server_performance.value)\n\nserver_multiple_parameters = LA.PVs((LAserver,('perf','run')))\npprint(server_multiple_parameters.info())\npprint(server_multiple_parameters.get())\n\nserver_multiple_devPars = LA.PVs((LAdev1,('time','frequency')),(LAserver,('statistics','perf')))\npprint(server_multiple_devPars.get())\n\n# setting\ndev1_frequency = LA.PVs((LAdev1,'frequency'))\ndev1_frequency.set([1.5])\ndev1_frequency.value\ndev1_multiple_parameters = LA.PVs([LAdev1,('frequency','coordinate')])\ndev1_multiple_parameters.set([8.,[3.,4.]])\n\n# subscribing\nldo = LA.PVs([LAdev1,'cycle'])\nldo.subscribe()# it will print image data periodically\nldo.unsubscribe()# cancel the subscruption\n\n# test for timeout, should timeout in 10s:\n#,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\n#``````````````````Observations```````````````````````````````````````````````\nTiming of Access.get using ipython on localhost.\n    from liteserver import liteAccess as LA\n    Host='localhost'\n    LAdev1   = Host+':dev1'\n    %timeit image = LA.Access.get((LAdev1,['image']))\n    145 µs ± 1.95 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)\n    image[(LAdev1,'image')]['value'].shape\n    (120, 160, 3)\nRetrieving time of 57600 values (120*160*3) is 145 µs,\nwhich corresponds to 400 mValues/s\n\nRetrieving time of 57600 values (120*160*3) 220 µs,\nwhich corresponds to 260 MValues/s (on entry-level workstation). \nIt was 400 MValues/s on top-level workstation.\nNote: Msgpack was 4% faster.\n#``````````````````Tips```````````````````````````````````````````````````````\n# To enable debugging: LA.PVs.Dbg = True\n# To enable transaction timing: LA.Channel.Perf = True\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasukhanov%2Fliteserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasukhanov%2Fliteserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasukhanov%2Fliteserver/lists"}