Hello,
I have just come across some issues:
- What once worked does not work any longer
- The source has changed a bit but I am receiving an error before the changes
- I have some Python3 source and a server via Flask and HTML
I am giving this source below to better make you understand what is happening on my end of the spectrum. Oh and…for some reason, the source only allows for non-like numerical values.
uname -a >>> Linux beaglebone 4.19.94-ti-r58
cat /etc/dogtag >>> BeagleBoard.org Debian Buster IoT Image 2020-04-06
…
For the uboot_overlay, here is the command to look it over w/ my overlay:
cat /boot/uEnv.txt >>> ###Overide capes with eeprom
uboot_overlay_addr0=/lib/firmware/BBORG_MOTOR-00A2.dtbo
oh and the source:
#!/usr/bin/python3
from flask import Flask, render_template
import Adafruit_BBIO.GPIO as GPIO
import Adafruit_BBIO.PWM as PWM
from time import sleep
class Motor:
def init(self, dir_pin, pwm_pin, pwm_freq):
self.dir_pin = dir_pin
self.pwm_pin = pwm_pin
self.value = 0
PWM.start(pwm_pin, 0, pwm_freq)
GPIO.setup(dir_pin, GPIO.OUT)
def set(self, value):
if value == self.value:
return
assert -100 <= value <= 100
if (value < 0) != (self.value < 0):
changing direction
PWM.set_duty_cycle(self.pwm_pin, 0)
GPIO.output(self.dir_pin, value < 0)
PWM.set_duty_cycle(self.pwm_pin, abs(value))
self.value = value
motor1 = Motor(dir_pin=“P8_18”, pwm_pin=“P9_16”, pwm_freq=1000)
motor2 = Motor(dir_pin=“P8_16”, pwm_pin=“P9_14”, pwm_freq=1000)
motor3 = Motor(dir_pin=“P8_14”, pwm_pin=“P8_13”, pwm_freq=1000)
motor4 = Motor(dir_pin=“P8_26”, pwm_pin=“P8_19”, pwm_freq=1000)
def set_motorOne(v1):
motor1.set(v1)
def set_motorTwo(v2):
motor2.set(v2)
def set_motorThree(v3):
motor3.set(v3)
def set_motorFour(v4):
motor4.set(v4)
app = Flask(name)
@app.route("/")
def homepage(title=“homepage”):
return render_template(“BootGoOne.html”, title=title)
def add_motors_routeOne(state, v1):
@app.route("/" + state, endpoint=state)
def handlerOne():
set_motorOne(v1)
if add_motors_routeOne == 0:
PWM.stop(“P9_16”)
else:
pass
return homepage(title=state)
add_motors_routeOne(“0”, 0)
add_motors_routeOne(‘40’, 40)
add_motors_routeOne(‘50’, 50)
add_motors_routeOne(‘60’, 60)
add_motors_routeOne(‘70’, 70)
add_motors_routeOne(‘80’, 80)
add_motors_routeOne(‘90’, 90)
add_motors_routeOne(‘100’, 100)
Okay…so:
- When I add another ‘add_motors_routeOne’ as a separate call under another motor, I get some odd behavior.
- For instance, ‘add_motors_routeTwo’, would begin to make issues with calling 'add_motors_routeTwo(“0”, 0) at the value 0.
Anyway…the issue is that it begins to be a sysfs issue or an assertion error on my part.
- For instance, ‘add_motors_routeTwo’, would begin to make issues with calling 'add_motors_routeTwo(“0”, 0) at the value 0.
Traceback (most recent call last):
File “Moto/motocape/MotorCapeOne/MotorCapeTwo.py”, line 92, in
add_motors_routeTwo(“0”, 0)
File “Moto/motocape/MotorCapeOne/MotorCapeTwo.py”, line 83, in add_motors_routeTwo
@app.route("/" + state, endpoint=state)
File “/usr/lib/python3/dist-packages/flask/app.py”, line 1250, in decorator
self.add_url_rule(rule, endpoint, f, **options)
File “/usr/lib/python3/dist-packages/flask/app.py”, line 66, in wrapper_func
return f(self, *args, **kwargs)
File “/usr/lib/python3/dist-packages/flask/app.py”, line 1221, in add_url_rule
‘existing endpoint function: %s’ % endpoint)
AssertionError: View function mapping is overwriting an existing endpoint function: 0
Above is where you can find my error with the current config. of the python3 source from above.
Seth