laserlib


Namelaserlib JSON
Version 0.1 PyPI version JSON
download
home_pagehttps://github.com/JackyZhang26/laserlib
SummaryA library for communication with laser model produced by Micro photons(Shanghai)Technology Co., Ltd.
upload_time2024-07-20 06:22:59
maintainerNone
docs_urlNone
authorJacky Zhang
requires_pythonNone
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## About
This lib is created for scanning laser module GC-76000C produced by Micro photons(Shanghai)Technology Co., Ltd. The tech documentation of it provided by the corporation is my reference.

It can send control parameters (such as starting frequency) to the module, and request informations from it.

## Usage
### Function definitions
Here is the usage of all functions in the `LaserSerial` class, including their parameters and return values:

1. **`__init__`**:
   - **Parameters**:
     - `port`: String, specifies the serial port name, default is 'COM6'.
     - `baudrate`: Integer, specifies the baud rate, default is 9600.
     - `bytesize`: Specifies the byte size, default is `serial.EIGHTBITS`.
     - `parity`: Specifies the parity bit, default is `serial.PARITY_NONE`.
     - `stopbits`: Specifies the stop bits, default is `serial.STOPBITS_ONE`.
     - `xonxoff`: Boolean, specifies whether to enable software flow control, default is False.
     - `rtscts`: Boolean, specifies whether to enable hardware flow control, default is False.
     - `dsrdtr`: Boolean, specifies whether to enable DSR/DTR flow control, default is False.
     - `timeout`: Integer or float, specifies the timeout in seconds, default is 2 seconds.
   - **Return Value**: None.

2. **`calcBIP4`**:
   - **Parameters**:
     - `data`: Byte sequence, the data for which the BIP4 checksum needs to be calculated.
   - **Return Value**:
     - The BIP4 checksum.

3. **`convertCommand`**:
   - **Parameters**:
     - `data`: Byte sequence, the command data that needs to be converted.
   - **Return Value**:
     - The converted command, including the BIP4 checksum.

4. **`sendCommand`**:
   - **Parameters**:
     - `data`: Byte sequence, the command data that needs to be sent.
   - **Return Value**: None.

5. **`checkResponse`**:
   - **Parameters**: None.
   - **Return Value**:
     - Boolean, True if the response's BIP4 checksum is correct, otherwise False.

*Actually, the above functions are basically not directly called in use, the following functions are more convenient for direct use*

6. **`send_starting_frequency`**:
   - **Parameters**:
     - `starting_frequency`: Integer, specifies the starting frequency. Can choose between 196250 and 191150 (Their physical unit are GHz).
   - **Return Value**:
     - Boolean, indicates whether the command was executed successfully, (`True` means your are successful).

7. **`send_scan_step`**:
   - **Parameters**:
     - `scan_step`: Integer, specifies the scan step value. Can be set to 1 or 2 (Their physical unit are GHz).
   - **Return Value**:
     - Boolean, indicates whether the command was executed successfully.

8. **`send_stop_frequency`**:
   - **Parameters**:
     - `stop_frequency`: Integer, specifies the stop frequency. Can choose between 196250 and 191150 (Their physical unit are GHz).
   - **Return Value**:
     - Boolean, indicates whether the command was executed successfully.

9. **`send_scan_speed`**:
   - **Parameters**:
     - `scan_speed`: Integer, specifies the scan speed. Can be set to 1, 2, 3, or 4.
   - **Return Value**:
     - Boolean, indicates whether the command was executed successfully.

10. **`send_scan_control_command`**:
    - **Parameters**:
      - `command`: Byte, specifies the scan control command. Can be set to 0x01, 0x02, 0x00, for single scan, continuous scan, and stop scan respectively.(In fact, python is so "smart" that you can use Integer 1, 2 or 0 instead of 0x01, 0x02, 0x00.)
    - **Return Value**:
      - Boolean, indicates whether the command was executed successfully.

11. **`read_serial_number`**:
    - **Parameters**: None.
    - **Return Value**:
      - Integer, the device's serial number.

12. **`read_firmware_version`**:
    - **Parameters**: None.
    - **Return Value**:
      - Integer, the device's firmware version number.

### Example
You can initialize your laser module as follows:

```python
import serial
from laserlib import LaserSerial

laser = LaserSerial(port='COM6', baudrate=9600)
# Default setting is 
#     port='COM6', baudrate=9600, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, xonxoff=False, rtscts=False, dsrdtr=False, timeout=2
```
Then you can use the functions like this:
```python
laser.send_starting_frequency(196250) #In fact, you can use the return value of this function, to ensure your command have been executed correctly. 
time.sleep(0.1) #It needs a delay time, but I dont know why...
laser.send_scan_step(1)
time.sleep(0.1)
laser.send_stop_frequency(191150)
time.sleep(0.1)
laser.send_scan_control_command(1)
time.sleep(0.1)
#You should set your laser module in above sequence.
laser.send_scan_speed(1)
time.sleep(0.1)
print(laser.read_serial_number())
time.sleep(0.1)
print(laser.read_firmware_version())
laser.closeSerial()
```

## License

This project is licensed under the MIT License - see the LICENSE file for details

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/JackyZhang26/laserlib",
    "name": "laserlib",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Jacky Zhang",
    "author_email": "jackyzhang26@outlook.com",
    "download_url": "https://files.pythonhosted.org/packages/a7/ee/0fdadccd4cd5974fd43884156b6f548d73ea1d0ffef43c1a16e4f708724a/laserlib-0.1.tar.gz",
    "platform": null,
    "description": "## About\r\nThis lib is created for scanning laser module GC-76000C produced by Micro photons(Shanghai)Technology Co., Ltd. The tech documentation of it provided by the corporation is my reference.\r\n\r\nIt can send control parameters (such as starting frequency) to the module, and request informations from it.\r\n\r\n## Usage\r\n### Function definitions\r\nHere is the usage of all functions in the `LaserSerial` class, including their parameters and return values:\r\n\r\n1. **`__init__`**:\r\n   - **Parameters**:\r\n     - `port`: String, specifies the serial port name, default is 'COM6'.\r\n     - `baudrate`: Integer, specifies the baud rate, default is 9600.\r\n     - `bytesize`: Specifies the byte size, default is `serial.EIGHTBITS`.\r\n     - `parity`: Specifies the parity bit, default is `serial.PARITY_NONE`.\r\n     - `stopbits`: Specifies the stop bits, default is `serial.STOPBITS_ONE`.\r\n     - `xonxoff`: Boolean, specifies whether to enable software flow control, default is False.\r\n     - `rtscts`: Boolean, specifies whether to enable hardware flow control, default is False.\r\n     - `dsrdtr`: Boolean, specifies whether to enable DSR/DTR flow control, default is False.\r\n     - `timeout`: Integer or float, specifies the timeout in seconds, default is 2 seconds.\r\n   - **Return Value**: None.\r\n\r\n2. **`calcBIP4`**:\r\n   - **Parameters**:\r\n     - `data`: Byte sequence, the data for which the BIP4 checksum needs to be calculated.\r\n   - **Return Value**:\r\n     - The BIP4 checksum.\r\n\r\n3. **`convertCommand`**:\r\n   - **Parameters**:\r\n     - `data`: Byte sequence, the command data that needs to be converted.\r\n   - **Return Value**:\r\n     - The converted command, including the BIP4 checksum.\r\n\r\n4. **`sendCommand`**:\r\n   - **Parameters**:\r\n     - `data`: Byte sequence, the command data that needs to be sent.\r\n   - **Return Value**: None.\r\n\r\n5. **`checkResponse`**:\r\n   - **Parameters**: None.\r\n   - **Return Value**:\r\n     - Boolean, True if the response's BIP4 checksum is correct, otherwise False.\r\n\r\n*Actually, the above functions are basically not directly called in use, the following functions are more convenient for direct use*\r\n\r\n6. **`send_starting_frequency`**:\r\n   - **Parameters**:\r\n     - `starting_frequency`: Integer, specifies the starting frequency. Can choose between 196250 and 191150 (Their physical unit are GHz).\r\n   - **Return Value**:\r\n     - Boolean, indicates whether the command was executed successfully, (`True` means your are successful).\r\n\r\n7. **`send_scan_step`**:\r\n   - **Parameters**:\r\n     - `scan_step`: Integer, specifies the scan step value. Can be set to 1 or 2 (Their physical unit are GHz).\r\n   - **Return Value**:\r\n     - Boolean, indicates whether the command was executed successfully.\r\n\r\n8. **`send_stop_frequency`**:\r\n   - **Parameters**:\r\n     - `stop_frequency`: Integer, specifies the stop frequency. Can choose between 196250 and 191150 (Their physical unit are GHz).\r\n   - **Return Value**:\r\n     - Boolean, indicates whether the command was executed successfully.\r\n\r\n9. **`send_scan_speed`**:\r\n   - **Parameters**:\r\n     - `scan_speed`: Integer, specifies the scan speed. Can be set to 1, 2, 3, or 4.\r\n   - **Return Value**:\r\n     - Boolean, indicates whether the command was executed successfully.\r\n\r\n10. **`send_scan_control_command`**:\r\n    - **Parameters**:\r\n      - `command`: Byte, specifies the scan control command. Can be set to 0x01, 0x02, 0x00, for single scan, continuous scan, and stop scan respectively.(In fact, python is so \"smart\" that you can use Integer 1, 2 or 0 instead of 0x01, 0x02, 0x00.)\r\n    - **Return Value**:\r\n      - Boolean, indicates whether the command was executed successfully.\r\n\r\n11. **`read_serial_number`**:\r\n    - **Parameters**: None.\r\n    - **Return Value**:\r\n      - Integer, the device's serial number.\r\n\r\n12. **`read_firmware_version`**:\r\n    - **Parameters**: None.\r\n    - **Return Value**:\r\n      - Integer, the device's firmware version number.\r\n\r\n### Example\r\nYou can initialize your laser module as follows:\r\n\r\n```python\r\nimport serial\r\nfrom laserlib import LaserSerial\r\n\r\nlaser = LaserSerial(port='COM6', baudrate=9600)\r\n# Default setting is \r\n#     port='COM6', baudrate=9600, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, xonxoff=False, rtscts=False, dsrdtr=False, timeout=2\r\n```\r\nThen you can use the functions like this:\r\n```python\r\nlaser.send_starting_frequency(196250) #In fact, you can use the return value of this function, to ensure your command have been executed correctly. \r\ntime.sleep(0.1) #It needs a delay time, but I dont know why...\r\nlaser.send_scan_step(1)\r\ntime.sleep(0.1)\r\nlaser.send_stop_frequency(191150)\r\ntime.sleep(0.1)\r\nlaser.send_scan_control_command(1)\r\ntime.sleep(0.1)\r\n#You should set your laser module in above sequence.\r\nlaser.send_scan_speed(1)\r\ntime.sleep(0.1)\r\nprint(laser.read_serial_number())\r\ntime.sleep(0.1)\r\nprint(laser.read_firmware_version())\r\nlaser.closeSerial()\r\n```\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License - see the LICENSE file for details\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A library for communication with laser model produced by Micro photons(Shanghai)Technology Co., Ltd.",
    "version": "0.1",
    "project_urls": {
        "Homepage": "https://github.com/JackyZhang26/laserlib"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4030fbdbc6ae974645d1a48c3074eaee6a8c7e0f0d2c9ab9ff6c033d6bcf7d0b",
                "md5": "e7c709c15190447eda4ff82701ba7a8e",
                "sha256": "52d2ce4baacc7c462776093cc0d7631d026700c8dc1feaa84c3e82cdf94129d1"
            },
            "downloads": -1,
            "filename": "laserlib-0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e7c709c15190447eda4ff82701ba7a8e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 4721,
            "upload_time": "2024-07-20T06:22:57",
            "upload_time_iso_8601": "2024-07-20T06:22:57.948059Z",
            "url": "https://files.pythonhosted.org/packages/40/30/fbdbc6ae974645d1a48c3074eaee6a8c7e0f0d2c9ab9ff6c033d6bcf7d0b/laserlib-0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a7ee0fdadccd4cd5974fd43884156b6f548d73ea1d0ffef43c1a16e4f708724a",
                "md5": "1ce435a478164a17ac69d6260b7c8c89",
                "sha256": "dd4be4cb7ff849171f8debf124e1233da83db7dc694607b2d71ba9f7c018d031"
            },
            "downloads": -1,
            "filename": "laserlib-0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "1ce435a478164a17ac69d6260b7c8c89",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4262,
            "upload_time": "2024-07-20T06:22:59",
            "upload_time_iso_8601": "2024-07-20T06:22:59.315687Z",
            "url": "https://files.pythonhosted.org/packages/a7/ee/0fdadccd4cd5974fd43884156b6f548d73ea1d0ffef43c1a16e4f708724a/laserlib-0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-20 06:22:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "JackyZhang26",
    "github_project": "laserlib",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "laserlib"
}
        
Elapsed time: 0.30915s