xarm-python-sdk 1.15.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. xarm/__init__.py +2 -0
  2. xarm/build_backend.py +17 -0
  3. xarm/core/__init__.py +2 -0
  4. xarm/core/comm/__init__.py +5 -0
  5. xarm/core/comm/base.py +303 -0
  6. xarm/core/comm/serial_port.py +44 -0
  7. xarm/core/comm/socket_port.py +150 -0
  8. xarm/core/comm/uxbus_cmd_protocol.py +100 -0
  9. xarm/core/config/__init__.py +0 -0
  10. xarm/core/config/x_code.py +1427 -0
  11. xarm/core/config/x_config.py +553 -0
  12. xarm/core/utils/__init__.py +3 -0
  13. xarm/core/utils/convert.py +124 -0
  14. xarm/core/utils/crc16.py +76 -0
  15. xarm/core/utils/debug_print.py +21 -0
  16. xarm/core/utils/log.py +98 -0
  17. xarm/core/version.py +1 -0
  18. xarm/core/wrapper/__init__.py +11 -0
  19. xarm/core/wrapper/uxbus_cmd.py +1457 -0
  20. xarm/core/wrapper/uxbus_cmd_ser.py +94 -0
  21. xarm/core/wrapper/uxbus_cmd_tcp.py +305 -0
  22. xarm/tools/__init__.py +0 -0
  23. xarm/tools/blockly/__init__.py +1 -0
  24. xarm/tools/blockly/_blockly_base.py +416 -0
  25. xarm/tools/blockly/_blockly_handler.py +1338 -0
  26. xarm/tools/blockly/_blockly_highlight.py +94 -0
  27. xarm/tools/blockly/_blockly_node.py +61 -0
  28. xarm/tools/blockly/_blockly_tool.py +480 -0
  29. xarm/tools/blockly_tool.py +1864 -0
  30. xarm/tools/gcode.py +90 -0
  31. xarm/tools/list_ports.py +39 -0
  32. xarm/tools/modbus_tcp.py +205 -0
  33. xarm/tools/threads.py +30 -0
  34. xarm/tools/utils.py +36 -0
  35. xarm/version.py +1 -0
  36. xarm/wrapper/__init__.py +1 -0
  37. xarm/wrapper/studio_api.py +34 -0
  38. xarm/wrapper/xarm_api.py +4416 -0
  39. xarm/x3/__init__.py +2 -0
  40. xarm/x3/base.py +2638 -0
  41. xarm/x3/base_board.py +198 -0
  42. xarm/x3/code.py +62 -0
  43. xarm/x3/decorator.py +104 -0
  44. xarm/x3/events.py +166 -0
  45. xarm/x3/ft_sensor.py +264 -0
  46. xarm/x3/gpio.py +457 -0
  47. xarm/x3/grammar_async.py +21 -0
  48. xarm/x3/grammar_coroutine.py +24 -0
  49. xarm/x3/gripper.py +830 -0
  50. xarm/x3/modbus_tcp.py +84 -0
  51. xarm/x3/parse.py +110 -0
  52. xarm/x3/record.py +216 -0
  53. xarm/x3/report.py +204 -0
  54. xarm/x3/robotiq.py +220 -0
  55. xarm/x3/servo.py +485 -0
  56. xarm/x3/studio.py +138 -0
  57. xarm/x3/track.py +424 -0
  58. xarm/x3/utils.py +43 -0
  59. xarm/x3/xarm.py +1928 -0
  60. xarm_python_sdk-1.15.2.dist-info/METADATA +103 -0
  61. xarm_python_sdk-1.15.2.dist-info/RECORD +63 -0
  62. xarm_python_sdk-1.15.2.dist-info/WHEEL +4 -0
  63. xarm_python_sdk-1.15.2.dist-info/licenses/LICENSE +27 -0
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env python3
2
+
3
+ #
4
+ # ./common_modules/crc16.py
5
+ # Copyright (C) 2018.4 - UFactory.
6
+ # Author: Jimy Zhang <jimy.zhang@ufactory.cc>
7
+ # <jimy92@163.com>
8
+ #
9
+
10
+
11
+ CRC_TABLE_H = (
12
+ 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00,
13
+ 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81,
14
+ 0x40, 0x01, 0xC0,
15
+ 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81,
16
+ 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01,
17
+ 0xC0, 0x80, 0x41,
18
+ 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00,
19
+ 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80,
20
+ 0x41, 0x01, 0xC0,
21
+ 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80,
22
+ 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00,
23
+ 0xC1, 0x81, 0x40,
24
+ 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00,
25
+ 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81,
26
+ 0x40, 0x01, 0xC0,
27
+ 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81,
28
+ 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01,
29
+ 0xC0, 0x80, 0x41,
30
+ 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00,
31
+ 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81,
32
+ 0x40, 0x01, 0xC0,
33
+ 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80,
34
+ 0x41, 0x01, 0xC0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6, 0xA7, 0x67, 0xA5, 0x65, 0x64, 0xA4, 0x6C, 0xAC, 0xAD, 0x6D, 0xAF,
50
+ 0x6F, 0x6E, 0xAE, 0xAA, 0x6A, 0x6B, 0xAB, 0x69, 0xA9, 0xA8, 0x68, 0x78, 0xB8, 0xB9, 0x79,
51
+ 0xBB, 0x7B, 0x7A, 0xBA, 0xBE, 0x7E, 0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75,
52
+ 0xB5, 0x77, 0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71, 0x70, 0xB0, 0x50, 0x90,
53
+ 0x91, 0x51, 0x93, 0x53, 0x52, 0x92, 0x96, 0x56, 0x57, 0x97, 0x55, 0x95, 0x94, 0x54, 0x9C,
54
+ 0x5C, 0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E, 0x5A, 0x9A, 0x9B, 0x5B, 0x99, 0x59, 0x58, 0x98,
55
+ 0x88, 0x48, 0x49, 0x89, 0x4B, 0x8B, 0x8A, 0x4A, 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C,
56
+ 0x8C, 0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86, 0x82, 0x42, 0x43, 0x83, 0x41, 0x81,
57
+ 0x80, 0x40)
58
+
59
+
60
+ def crc_modbus(data):
61
+ leng = len(data)
62
+ init_crch = 0xFF
63
+ init_crcl = 0xFF
64
+ i = 0
65
+
66
+ while leng > 0:
67
+ index = init_crch ^ data[i]
68
+ i += 1
69
+ init_crch = init_crcl ^ CRC_TABLE_H[index]
70
+ init_crcl = CRC_TABLE_L[index]
71
+ leng -= 1
72
+ s = init_crch << 8 | init_crcl
73
+ crc = bytes([s // 256 % 256])
74
+ crc += bytes([s % 256])
75
+ return crc
76
+
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: UTF-8 -*-
3
+
4
+ #
5
+ # ./common_modules/debug_print.py
6
+ # Copyright (C) 2018.4 - UFactory.
7
+ # Author: Jimy Zhang <jimy.zhang@ufactory.cc>
8
+ # <jimy92@163.com>
9
+ #
10
+
11
+
12
+ def print_hex(str, data, len):
13
+ for i in range(len):
14
+ str += ('%0.2X ' % data[i])
15
+ print(str)
16
+
17
+
18
+ def print_nvect(str, data, len):
19
+ for i in range(len):
20
+ str += ('%0.3f ' % data[i])
21
+ print(str)
xarm/core/utils/log.py ADDED
@@ -0,0 +1,98 @@
1
+ #!/usr/bin/env python3
2
+ # Software License Agreement (BSD License)
3
+ #
4
+ # Copyright (c) 2018, UFACTORY, Inc.
5
+ # All rights reserved.
6
+ #
7
+ # Author: Vinman <vinman.wen@ufactory.cc> <vinman.cub@gmail.com>
8
+
9
+ import logging
10
+ import functools
11
+ import sys
12
+ import os
13
+
14
+ log_path = os.path.join(os.path.expanduser('~'), '.UFACTORY', 'log', 'xarm', 'sdk')
15
+ if not os.path.exists(log_path):
16
+ os.makedirs(log_path)
17
+
18
+ logging.VERBOSE = 5
19
+ logging.addLevelName(logging.VERBOSE, 'VERBOSE')
20
+
21
+
22
+ class Logger(logging.Logger):
23
+ logger_fmt = '{}[%(levelname)s][%(asctime)s][%(filename)s:%(lineno)d] - - %(message)s'
24
+ logger_date_fmt = '%Y-%m-%d %H:%M:%S'
25
+ stream_handler_fmt = logger_fmt.format('[SDK]')
26
+ stream_handler_date_fmt = logger_date_fmt
27
+ stream_handler = logging.StreamHandler(sys.stdout)
28
+ stream_handler.setLevel(logging.VERBOSE)
29
+ stream_handler.setFormatter(logging.Formatter(stream_handler_fmt, stream_handler_date_fmt))
30
+
31
+ logger = logging.Logger(__name__)
32
+ logger.setLevel(logging.VERBOSE)
33
+ logger.addHandler(stream_handler)
34
+
35
+ def __new__(cls, *args, **kwargs):
36
+ if not hasattr(cls, 'logger'):
37
+ cls.logger = super(Logger, cls).__new__(cls, *args, **kwargs)
38
+ return cls.logger
39
+
40
+ logger = Logger(__name__)
41
+ logger.setLevel(logging.WARNING)
42
+
43
+ logger.VERBOSE = logging.VERBOSE
44
+ logger.DEBUG = logging.DEBUG
45
+ logger.INFO = logging.INFO
46
+ logger.WARN = logging.WARN
47
+ logger.WARNING = logging.WARNING
48
+ logger.ERROR = logging.ERROR
49
+ logger.CRITICAL = logging.CRITICAL
50
+
51
+ logger.verbose = functools.partial(logger.log, logger.VERBOSE)
52
+
53
+ # findCaller = logger.findCaller
54
+ #
55
+ #
56
+ # def log(msg, *args, **kwargs):
57
+ # level = kwargs.pop('level', logger.INFO)
58
+ # if logger.findCaller == findCaller:
59
+ # rv = findCaller(kwargs.pop('stack_info', False))
60
+ # logger.findCaller = lambda x: rv
61
+ # logger.log(level, msg, *args, **kwargs)
62
+ # if logger.findCaller != findCaller:
63
+ # logger.findCaller = findCaller
64
+ #
65
+ # logger.verbose = functools.partial(log, level=logger.VERBOSE)
66
+ # logger.debug = functools.partial(log, level=logger.DEBUG)
67
+ # logger.info = functools.partial(log, level=logger.INFO)
68
+ # logger.warning = functools.partial(log, level=logger.WARNING)
69
+ # logger.error = functools.partial(log, level=logger.ERROR)
70
+ # logger.critical = functools.partial(log, level=logger.CRITICAL)
71
+
72
+ colors = {
73
+ 'none': '{}',
74
+ 'white': '\033[30m{}\033[0m',
75
+ 'red': '\033[31m{}\033[0m',
76
+ 'green': '\033[32m{}\033[0m',
77
+ 'orange': '\033[33m{}\033[0m',
78
+ 'blue': '\033[34m{}\033[0m',
79
+ 'purple': '\033[35m{}\033[0m',
80
+ 'cyan': '\033[36m{}\033[0m',
81
+ 'light_gray': '\033[37m{}\033[0m',
82
+ 'dark_gray': '\033[90m{}\033[0m',
83
+ 'light_red': '\033[91m{}\033[0m',
84
+ 'light_green': '\033[92m{}\033[0m',
85
+ 'yellow': '\033[93m{}\033[0m',
86
+ 'light_blue': '\033[94m{}\033[0m',
87
+ 'pink': '\033[95m{}\033[0m',
88
+ 'light_cyan': '\033[96m{}\033[0m',
89
+ }
90
+
91
+
92
+ def pretty_print(*args, sep=' ', end='\n', file=None, color='none'):
93
+ msg = ''
94
+ for arg in args:
95
+ msg += arg + sep
96
+ msg = msg.rstrip(sep)
97
+ # msg = colors.get(color, '{}').format(msg)
98
+ print(msg, end=end, file=file)
xarm/core/version.py ADDED
@@ -0,0 +1 @@
1
+ __version__ = '0.1.0'
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env python3
2
+ # Software License Agreement (MIT License)
3
+ #
4
+ # Copyright (c) 2018, UFACTORY, Inc.
5
+ # All rights reserved.
6
+ #
7
+ # Author: Vinman <vinman.wen@ufactory.cc>
8
+
9
+
10
+ from .uxbus_cmd_ser import UxbusCmdSer
11
+ from .uxbus_cmd_tcp import UxbusCmdTcp