diff options
author | CoprDistGit <infra@openeuler.org> | 2023-05-31 05:44:53 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-05-31 05:44:53 +0000 |
commit | 054bc52261363c9c5bf95606434bd7e1030d11cc (patch) | |
tree | 809d04016eda2dfa90590d5886e15160ede08209 | |
parent | 6ab06ceb786fcf3a6a7e29dbb954b4bc430ea223 (diff) |
automatic import of python-vsmd
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-vsmd.spec | 415 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 417 insertions, 0 deletions
@@ -0,0 +1 @@ +/VSMD-0.2.8.tar.gz diff --git a/python-vsmd.spec b/python-vsmd.spec new file mode 100644 index 0000000..7af5950 --- /dev/null +++ b/python-vsmd.spec @@ -0,0 +1,415 @@ +%global _empty_manifest_terminate_build 0 +Name: python-VSMD +Version: 0.2.8 +Release: 1 +Summary: Controller for VSMD CAN motor +License: GNU General Public License v3 (GPLv3) +URL: https://github.com/JChrysanthemum/VSMD +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/c1/fd/11020291deeec17242e73e28f159c90850f94e231fd4b2253328b105f296/VSMD-0.2.8.tar.gz +BuildArch: noarch + +Requires: python3-can + +%description +# VSMD + +Controller for VSMD can motor + +## Debug model + +Explained by doc file +[VSMD1X6_SERIES_V1.0.pdf](https://github.com/JChrysanthemum/VSMD/blob/master/doc/VSMD1X6_SERIES_V1.0.pdf), it's +easy to convert can.message to meaningful frame. + +``` +bus = can.interface.Bus(bustype='socketcan', channel='can0', bitrate=500000) + +while True: + for msg in bus: + print("\n%2d\n" % cnt) + + # set debug = true make it to show inf of can-frame + can_frame = VsmdCanFrame(msg, debug=True) +``` + +For an example,say frame 0004079F#0020000000000000 , it can be interpreted as below: +``` +************************************************************ +| Main: | ++ Raw : 0004079f#0020000000000000 ++ Sender : vcan0 ++ Extent ID Frame : 00000000001000000011110011111 ++ DLC : 8 ++ Data Frame : ['00200000', '00000000'] + +| Extend ID Frame | ++ Source Device : Pi ++ Target Device : BroadCast ++ Command Word : 11 ++ CMD or Register ADR : READ_DATA_REGS + +| Action | ++ CW Means : CMD +| Data Frame | ++ Command : [('Data Reg Start:', <DataRegTable.CID: ['0000000', 'Channel ID', 'Determined by motor']>), ('Data Reg count:', 32)] +************************************************************ +``` + +## Quick VSMD-CAN setup and drive + +See in CommonCMD in [VSMD1X6.py](https://github.com/JChrysanthemum/VSMD/blob/master/vsmd/VSMD1X6.py) + + +## Generate your own CMD + +I have sealed most type of command of VSMD in script,you can import them like this: + +``` +from VSMD import CommonCMD +``` + +Which contains these sub-function: + +* enable_motor(device: str) + + ENA 0x01 + + CAN motor is allowed to move after ENA is ON + +* disable_motor(device: str) + + OFF 0x02 + + Make CAN motor ignore move cmd. Often used for broadcast + +* move_motor(device: str, speed: int) + + MOV 0x05 + + Move motor with specific speed. This is somehow dangerous + +* stop_motor(device: str) + + STP 0x04 + + Stop the motor now. + +* move_to(device: str, pos: int) + + POS 0x06 + + Mode to absolute pos. + +* move_dis(device: str, dis: int) + + RMV 0x0B + + Mode to relative pos. + +* read_status_regs(device: str, reg: StatusRegTable, cnt: int) + + READ STATUS REGS 0x1E + + Follow the PDF + +* read_data_regs(device: str, reg: DataRegTable, cnt: int) + + READ DATA REGS 0x1F + + Follow the PDF + +* write_data_regs(device: str, reg: DataRegTable, data): + + Note that you must use save after write some registers + + + + + + +%package -n python3-VSMD +Summary: Controller for VSMD CAN motor +Provides: python-VSMD +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-VSMD +# VSMD + +Controller for VSMD can motor + +## Debug model + +Explained by doc file +[VSMD1X6_SERIES_V1.0.pdf](https://github.com/JChrysanthemum/VSMD/blob/master/doc/VSMD1X6_SERIES_V1.0.pdf), it's +easy to convert can.message to meaningful frame. + +``` +bus = can.interface.Bus(bustype='socketcan', channel='can0', bitrate=500000) + +while True: + for msg in bus: + print("\n%2d\n" % cnt) + + # set debug = true make it to show inf of can-frame + can_frame = VsmdCanFrame(msg, debug=True) +``` + +For an example,say frame 0004079F#0020000000000000 , it can be interpreted as below: +``` +************************************************************ +| Main: | ++ Raw : 0004079f#0020000000000000 ++ Sender : vcan0 ++ Extent ID Frame : 00000000001000000011110011111 ++ DLC : 8 ++ Data Frame : ['00200000', '00000000'] + +| Extend ID Frame | ++ Source Device : Pi ++ Target Device : BroadCast ++ Command Word : 11 ++ CMD or Register ADR : READ_DATA_REGS + +| Action | ++ CW Means : CMD +| Data Frame | ++ Command : [('Data Reg Start:', <DataRegTable.CID: ['0000000', 'Channel ID', 'Determined by motor']>), ('Data Reg count:', 32)] +************************************************************ +``` + +## Quick VSMD-CAN setup and drive + +See in CommonCMD in [VSMD1X6.py](https://github.com/JChrysanthemum/VSMD/blob/master/vsmd/VSMD1X6.py) + + +## Generate your own CMD + +I have sealed most type of command of VSMD in script,you can import them like this: + +``` +from VSMD import CommonCMD +``` + +Which contains these sub-function: + +* enable_motor(device: str) + + ENA 0x01 + + CAN motor is allowed to move after ENA is ON + +* disable_motor(device: str) + + OFF 0x02 + + Make CAN motor ignore move cmd. Often used for broadcast + +* move_motor(device: str, speed: int) + + MOV 0x05 + + Move motor with specific speed. This is somehow dangerous + +* stop_motor(device: str) + + STP 0x04 + + Stop the motor now. + +* move_to(device: str, pos: int) + + POS 0x06 + + Mode to absolute pos. + +* move_dis(device: str, dis: int) + + RMV 0x0B + + Mode to relative pos. + +* read_status_regs(device: str, reg: StatusRegTable, cnt: int) + + READ STATUS REGS 0x1E + + Follow the PDF + +* read_data_regs(device: str, reg: DataRegTable, cnt: int) + + READ DATA REGS 0x1F + + Follow the PDF + +* write_data_regs(device: str, reg: DataRegTable, data): + + Note that you must use save after write some registers + + + + + + +%package help +Summary: Development documents and examples for VSMD +Provides: python3-VSMD-doc +%description help +# VSMD + +Controller for VSMD can motor + +## Debug model + +Explained by doc file +[VSMD1X6_SERIES_V1.0.pdf](https://github.com/JChrysanthemum/VSMD/blob/master/doc/VSMD1X6_SERIES_V1.0.pdf), it's +easy to convert can.message to meaningful frame. + +``` +bus = can.interface.Bus(bustype='socketcan', channel='can0', bitrate=500000) + +while True: + for msg in bus: + print("\n%2d\n" % cnt) + + # set debug = true make it to show inf of can-frame + can_frame = VsmdCanFrame(msg, debug=True) +``` + +For an example,say frame 0004079F#0020000000000000 , it can be interpreted as below: +``` +************************************************************ +| Main: | ++ Raw : 0004079f#0020000000000000 ++ Sender : vcan0 ++ Extent ID Frame : 00000000001000000011110011111 ++ DLC : 8 ++ Data Frame : ['00200000', '00000000'] + +| Extend ID Frame | ++ Source Device : Pi ++ Target Device : BroadCast ++ Command Word : 11 ++ CMD or Register ADR : READ_DATA_REGS + +| Action | ++ CW Means : CMD +| Data Frame | ++ Command : [('Data Reg Start:', <DataRegTable.CID: ['0000000', 'Channel ID', 'Determined by motor']>), ('Data Reg count:', 32)] +************************************************************ +``` + +## Quick VSMD-CAN setup and drive + +See in CommonCMD in [VSMD1X6.py](https://github.com/JChrysanthemum/VSMD/blob/master/vsmd/VSMD1X6.py) + + +## Generate your own CMD + +I have sealed most type of command of VSMD in script,you can import them like this: + +``` +from VSMD import CommonCMD +``` + +Which contains these sub-function: + +* enable_motor(device: str) + + ENA 0x01 + + CAN motor is allowed to move after ENA is ON + +* disable_motor(device: str) + + OFF 0x02 + + Make CAN motor ignore move cmd. Often used for broadcast + +* move_motor(device: str, speed: int) + + MOV 0x05 + + Move motor with specific speed. This is somehow dangerous + +* stop_motor(device: str) + + STP 0x04 + + Stop the motor now. + +* move_to(device: str, pos: int) + + POS 0x06 + + Mode to absolute pos. + +* move_dis(device: str, dis: int) + + RMV 0x0B + + Mode to relative pos. + +* read_status_regs(device: str, reg: StatusRegTable, cnt: int) + + READ STATUS REGS 0x1E + + Follow the PDF + +* read_data_regs(device: str, reg: DataRegTable, cnt: int) + + READ DATA REGS 0x1F + + Follow the PDF + +* write_data_regs(device: str, reg: DataRegTable, data): + + Note that you must use save after write some registers + + + + + + +%prep +%autosetup -n VSMD-0.2.8 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-VSMD -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Wed May 31 2023 Python_Bot <Python_Bot@openeuler.org> - 0.2.8-1 +- Package Spec generated @@ -0,0 +1 @@ +bf3cecf2e73036e766740579c96b1518 VSMD-0.2.8.tar.gz |