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:
-
__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 isserial.EIGHTBITS.parity: Specifies the parity bit, default isserial.PARITY_NONE.stopbits: Specifies the stop bits, default isserial.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.
- Parameters:
-
calcBIP4:- Parameters:
data: Byte sequence, the data for which the BIP4 checksum needs to be calculated.
- Return Value:
- The BIP4 checksum.
- Parameters:
-
convertCommand:- Parameters:
data: Byte sequence, the command data that needs to be converted.
- Return Value:
- The converted command, including the BIP4 checksum.
- Parameters:
-
sendCommand:- Parameters:
data: Byte sequence, the command data that needs to be sent.
- Return Value: None.
- Parameters:
-
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
-
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, (
Truemeans your are successful).
- Boolean, indicates whether the command was executed successfully, (
- Parameters:
-
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.
- Parameters:
-
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.
- Parameters:
-
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.
- Parameters:
-
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.
- Parameters:
-
read_serial_number:- Parameters: None.
- Return Value:
- Integer, the device's serial number.
-
read_firmware_version:- Parameters: None.
- Return Value:
- Integer, the device's firmware version number.
Example
You can initialize your laser module as follows:
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:
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
Release files for laserlib 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| laserlib-0.1.tar.gz | 4.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| laserlib-0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.0 kB
Release files / laserlib-0.1.tar.gz
| Download URL | laserlib-0.1.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dd4be4cb7ff849171f8debf124e1233da83db7dc694607b2d71ba9f7c018d031
|
|
BLAKE2b-256 checksum How to use checksums |
a7ee0fdadccd4cd5974fd43884156b6f548d73ea1d0ffef43c1a16e4f708724a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Release files / laserlib-0.1-py3-none-any.whl
| Download URL | laserlib-0.1-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
52d2ce4baacc7c462776093cc0d7631d026700c8dc1feaa84c3e82cdf94129d1
|
|
BLAKE2b-256 checksum How to use checksums |
4030fbdbc6ae974645d1a48c3074eaee6a8c7e0f0d2c9ab9ff6c033d6bcf7d0b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|