From 129d26ed5eea45cab899387bde81619554acd0b0 Mon Sep 17 00:00:00 2001 From: Nikolay Khabarov <2xl@mail.ru> Date: Sun, 9 Jul 2017 03:19:04 +0300 Subject: [PATCH] run on oses without /proc/cpuinfo and fix lines width --- .DS_Store | Bin 0 -> 6148 bytes cnc/config.py | 19 ++++++++-------- cnc/gmachine.py | 4 ++-- cnc/hal_raspberry/rpgpio_private.py | 34 ++++++++++++++++------------ 4 files changed, 31 insertions(+), 26 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..0cc65c5e784cdf9a88807f61f746971d462f88a9 GIT binary patch literal 6148 zcmeHK-HOvd6h5{&xlVyIZ0GMKtJ#x%c-WM(+F&CX!GrZ=OulTmIFX zgh7%vo8Q<@sa(0TYnY~CUNhc0<9P0*ZaPak?)0^|3jCp`+DCC5{%*V8%V0P^uH8J0 zqtp$e;WR^k^D2n^c;1O;k)Mb-&)swkUop{ft-f5g9^7kKciXFmwQRSW4eS2?{%U0y z_1mpS{gczh`{jq#$8&iT7`{=$ZYcZ(pV3g+ojKDejH3~HINKzjhBTp&Vp`B1B{VLm z^aZS}O1t!g`gBM=dPWZQ@@!TwuniG;gy=l>8I213PX&IJp3(s#_vtZaaOenr0YwF` z?**?4GFV)CkIysr*rXSTdq7>x(?jf2^7FBY=bQDY(v)U+dQ#|=piVZaB=XLBncxk< zo?&HsSlPRcnP)wWoCosBuZ!`Vv;4}R73Go9t#B<7JuoI+fzp+! zBL-7v2PWMyZY%y;qI4%FW=0$}GgBuNrj8!W5_Dp=L|tnIv;uhrO7gPC_y6AI=l{Hu zzS0V41-427R_;384pLHk>xJa_UTdM8pm5{7wM5~9N^QrY!MEaDD8evi@dnUVxR!_> QnEnwEGU!Sx@J|)^2~~gSDgXcg literal 0 HcmV?d00001 diff --git a/cnc/config.py b/cnc/config.py index 7351e4b..4b91ab1 100644 --- a/cnc/config.py +++ b/cnc/config.py @@ -1,4 +1,4 @@ -# ------------------------------------------------------------------------------ +# ----------------------------------------------------------------------------- # Hardware config. # Maximum velocity for each axis in millimeter per minute. @@ -23,9 +23,9 @@ STEPPER_INVERTED_Y = False STEPPER_INVERTED_Z = False STEPPER_INVERTED_E = True -# Invert zero end stops switches. By default(False) low level on input pin means -# that axis in zero position. For inverted(True) end stops, high level means -# zero position. +# Invert zero end stops switches. By default(False) low level on input pin +# means that axis in zero position. For inverted(True) end stops, high level +# means zero position. ENDSTOP_INVERTED_X = True ENDSTOP_INVERTED_Y = True ENDSTOP_INVERTED_Z = True @@ -49,7 +49,7 @@ BED_PID = {"P": 5.06820175723, "I": 0.0476413193519, "D": 4.76413193519} -# ------------------------------------------------------------------------------ +# ----------------------------------------------------------------------------- # Pins configuration. STEPPER_STEP_PIN_X = 16 @@ -73,7 +73,7 @@ ENDSTOP_PIN_X = 12 ENDSTOP_PIN_Y = 6 ENDSTOP_PIN_Z = 5 -# ------------------------------------------------------------------------------ +# ----------------------------------------------------------------------------- # Behavior config # Run command immediately after receiving and stream new pulses, otherwise @@ -82,7 +82,8 @@ ENDSTOP_PIN_Z = 5 # enough for streaming pulses(faster then real time). INSTANT_RUN = True -# If this parameter is False, error will be raised on command with velocity more -# than maximum velocity specified here. If this parameter is True, velocity -# Would be decreased(proportional for all axises) to fit the maximum velocity. +# If this parameter is False, error will be raised on command with velocity +# more than maximum velocity specified here. If this parameter is True, +# velocity would be decreased(proportional for all axises) to fit the maximum +# velocity. AUTO_VELOCITY_ADJUSTMENT = True diff --git a/cnc/gmachine.py b/cnc/gmachine.py index 9a6d95c..e79b7f0 100644 --- a/cnc/gmachine.py +++ b/cnc/gmachine.py @@ -241,8 +241,8 @@ class GMachine(object): def safe_zero(self, x=True, y=True, z=True): """ Move head to zero position safely. :param x: boolean, move X axis to zero - :param y: boolean, move X axis to zero - :param z: boolean, move X axis to zero + :param y: boolean, move Y axis to zero + :param z: boolean, move Z axis to zero """ if x and not y: self._move_linear(Coordinates(-self._position.x, 0, 0, 0), diff --git a/cnc/hal_raspberry/rpgpio_private.py b/cnc/hal_raspberry/rpgpio_private.py index 84bf514..dca139c 100644 --- a/cnc/hal_raspberry/rpgpio_private.py +++ b/cnc/hal_raspberry/rpgpio_private.py @@ -12,21 +12,25 @@ import ctypes RPI1_PERI_BASE = 0x20000000 RPI2_3_PERI_BASE = 0x3F000000 # detect board version -with open("/proc/cpuinfo", "r") as f: - d = f.read() - r = re.search("^Revision\s+:\s+(.+)$", d, flags=re.MULTILINE) - h = re.search("^Hardware\s+:\s+(.+)$", d, flags=re.MULTILINE) - RPI_1_REVISIONS = ['0002', '0003', '0004', '0005', '0006', '0007', '0008', - '0009', '000d', '000e', '000f', '0010', '0011', '0012', - '0013', '0014', '0015', '900021', '900032'] - if h is None: - raise ImportError("This is not raspberry pi board.") - elif r.group(1) in RPI_1_REVISIONS: - PERI_BASE = RPI1_PERI_BASE - elif "BCM2" in h.group(1): - PERI_BASE = RPI2_3_PERI_BASE - else: - raise ImportError("Unknown board.") +try: + with open("/proc/cpuinfo", "r") as f: + d = f.read() + r = re.search("^Revision\s+:\s+(.+)$", d, flags=re.MULTILINE) + h = re.search("^Hardware\s+:\s+(.+)$", d, flags=re.MULTILINE) + RPI_1_REVISIONS = ['0002', '0003', '0004', '0005', '0006', '0007', + '0008', '0009', '000d', '000e', '000f', '0010', + '0011', '0012', '0013', '0014', '0015', '900021', + '900032'] + if h is None: + raise ImportError("This is not raspberry pi board.") + elif r.group(1) in RPI_1_REVISIONS: + PERI_BASE = RPI1_PERI_BASE + elif "BCM2" in h.group(1): + PERI_BASE = RPI2_3_PERI_BASE + else: + raise ImportError("Unknown board.") +except IOError: + raise ImportError("/proc/cpuinfo not found. Not Linux device?") PAGE_SIZE = 4096 GPIO_REGISTER_BASE = 0x200000 GPIO_INPUT_OFFSET = 0x34