;;; -*- lexical-binding: t -*- ;; ;; this file: ;; https://dataswamp.org/~incal/terror-3/ev3-motor-init.el (require 'cl-lib) (require 'ev3-base) (require 'file-write-to) (defvar left-motor-speed-file nil) (defvar right-motor-speed-file nil) (defvar m-motor-speed-file nil) (defvar left-motor-cmd-file nil) (defvar right-motor-cmd-file nil) (defvar m-motor-cmd-file nil) (let ((left-motor-path) (right-motor-path) (m-motor-path) ) (defun motor-init-check () (message "left-motor-path: %s" left-motor-path) (message "right-motor--path: %s" right-motor-path) (message "m-motor-path: %s" m-motor-path) (message "left-motor-speed-file: %s" left-motor-speed-file) (message "right-motor-speed-file: %s" right-motor-speed-file) (message "m-motor-speed-file: %s" m-motor-speed-file) (message "left-motor-cmd-file: %s" left-motor-cmd-file) (message "right-motor-cmd-file: %s" right-motor-cmd-file) (message "m-motor-cmd-file: %s" m-motor-cmd-file) ) (declare-function motor-init-check nil) (defun motor-init () (cl-loop for i from 0 to 2 do (let*((path (format "%s/tacho-motor/motor%d" ev3-base-path i)) (type-file (concat path "/driver_name")) (port-file (concat path "/address")) (port (file-to-string port-file)) (type (file-to-string type-file)) ) (when (and (string= "lego-ev3-l-motor" type) ; right (string= "ev3-ports:outB" port) ) (setq right-motor-path path) ) (when (and (string= "lego-ev3-l-motor" type) ; left (string= "ev3-ports:outC" port) ) (setq left-motor-path path) ) (when (string= "lego-ev3-m-motor" type) ; m (setq m-motor-path path) ))) (let ((speed-path "/speed_sp")) (setq left-motor-speed-file (concat left-motor-path speed-path)) (setq right-motor-speed-file (concat right-motor-path speed-path)) (setq m-motor-speed-file (concat m-motor-path speed-path)) ) (let ((cmd-path "/command")) (setq left-motor-cmd-file (concat left-motor-path cmd-path)) (setq right-motor-cmd-file (concat right-motor-path cmd-path)) (setq m-motor-cmd-file (concat m-motor-path cmd-path)) ) (motor-init-check) ) (declare-function motor-init nil) ) (provide 'ev3-motor-init)