How to use SIM800l in esp8266 in micropython - esp8266

I have a code :
from machine import UART, Pin
TERMINATION_CHAR = '\x1a'
TXD_PIN = 1
RXD_PIN = 3
RST_PIN = 5
RST = Pin(RST_PIN, mode=Pin.OUT)
RST.value(0)
uart = UART(1, baudrate=115200, pins=(TXD_PIN, RXD_PIN))
RST.value(1)
But it is showing a error
Traceback (most recent call last):
File "<stdin>", line 11, in <module>
TypeError: extra keyword arguments given

According to the Micropython UART documentation :
On the WiPy only the following keyword-only parameter is supported: pins.
No other Micropython port supports "pins" keyword parameter on the UART constructor call.
So you need to remove the pins argument; also, you should use UART 0, since in the esp8266 UART 1 is used for debug output only:
uart = UART(0, baudrate=115200)
On the esp8266 you cannot change the pins used by UART0 or UART1, the pins are fixed for each UART. Refer for the documentation for your particular esp8266 board to find which pins are used for the UART.

Related

DEAP mutation function receives parameters out of order

I'm struggling to get the deap.tools.mutUniformInt mutation function to work. To isolate the issue for this SO question, I changed line 62 of examples/ga/onemax.py from
toolbox.register("mutate", tools.mutFlipBit, indpb=0.05)
to
toolbox.register("mutate", tools.mutUniformInt, 0, 1, indpb=0.05)
The onemax.py example now fails:
C:\Users\mshiv\DEAP>python onemax.py
Start of evolution
Evaluated 300 individuals
-- Generation 1 --
Traceback (most recent call last):
File "C:\Users\mshiv\DEAP\onemax.py", line 161, in <module>
main()
File "C:\Users\mshiv\DEAP\onemax.py", line 128, in main
toolbox.mutate(mutant)
File "C:\Users\mshiv\AppData\Local\Programs\Python\Python39\lib\site-packages\deap\tools\mutation.py", line 159, in mutUniformInt
size = len(individual)
TypeError: object of type 'int' has no len()
Both mutators should operate on an Individual, which is defined in onemax.py to be a list, so why does mutFlipBit work, but mutUniformInt seems to receive the Individual parameter as an int, not a list?
Poking around in the DEAP code, I found that mutUniformInt receives the parameters out of order, i.e. they are passed in as (low, up, individual, indpb) whereas the function itself is defined as
def mutUniformInt(individual, low, up, indpb):
Am I registering this mutation function incorrectly?
Source of the onemax example I altered:
https://github.com/DEAP/deap/blob/master/examples/ga/onemax.py
NVM - found the answer here:
https://groups.google.com/g/deap-users/c/4sw2_Al4YFI/m/EvUiq70IBAAJ
The correct syntax should have been:
toolbox.register("mutate", tools.mutUniformInt, low=0, up=1, indpb=0.05)

Why I get a problem that tells me to set the value to float, and when I do I get I need to set it to integer?

I'm trying to save a recording of camera, Im using a free course, and it says, I need to create cv2.VideoWriter.
the problem I get when I try is:
Traceback (most recent call last):
File ..., line 10, in <module>
writer = cv2.VideoWriter(filename,cv2.VideoWriter_fourcc(*'DVIX'),20,(width,height))
TypeError: a float is required
my code:
import cv2
import numpy as np
cap = cv2.VideoCapture(0)
width = cap.get(cv2.CAP_PROP_FRAME_WIDTH)
height = cap.get(cv2.CAP_PROP_FRAME_HEIGHT)
#### THE PROBLEM IS IN THIS LINE ########
writer = cv2.VideoWriter("images/my_super_vid.mp4",cv2.VideoWriter_fourcc(*'DVIX'),20,(width,height))
######################################
while True:
ret, frame = cap.read()
#OPERTAIONS (DRAWING ETC')
writer.write(frame)
cv2.imshow("frame",frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
writer.release()
cv2.destroyAllWindows()
I saw the problem and I changed it to:
writer = cv2.VideoWriter("images/my_super_vid.mp4",cv2.VideoWriter_fourcc(*'DVIX'),float(20),(width,height))
and even:
writer = cv2.VideoWriter("images/my_super_vid.mp4",cv2.VideoWriter_fourcc(*'DVIX'),20.0,(width,height))
but in both of those tries I got:
Traceback (most recent call last):
File "....", line 10, in <module>
writer = cv2.VideoWriter("images/my_super_vid.mp4",cv2.VideoWriter_fourcc(*'DVIX'),20.0,(width,height))
TypeError: integer argument expected, got float
I don't know how to fix it, I tried solutions I saw in the internet but none of them worked..
got the same problem
okay I changed the line to:
writer = cv2.VideoWriter("images/my_super_vid.avi",cv2.VideoWriter_fourcc(*'XVID'),20, (int(width),int(height)))
and it worked. but now I get:
qt.qpa.plugin: Could not find the Qt platform plugin "cocoa" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
when I try to run it in PyCharm
FIXED IT: just ran it from terminal.
The errors are referring to different values on the same line in the parentheses. The first value has to be a float and second an int (or vice versa)

Encoding mismatch in connection and Python

I am having some troubles getting my Firebird connection to work, and it all seems related to encodings. I am connecting to the database like this (local_copy is /path/to/database.fdb):
conn = fdb.connect(dsn=local_copy, user='****', password='****', charset="ISO8859_1")
which only works for certain charsets. I need to have the ISO8859_1 charset, which worked before, but not anymore (perhaps because of an update).
Traceback (most recent call last):
File "sync.py", line 10, in <module>
conn = fdb.connect(dsn=local_copy, user='**', password='**', charset="ISO8859_1")
File "/usr/local/lib/python3.6/site-packages/fdb/fbcore.py", line 848, in connect
"Error while connecting to database:")
fdb.fbcore.DatabaseError: ('Error while connecting to database:\n- SQLCODE: -924\n- bad parameters on attach or create database\n- CHARACTER SET ISO8859_1 is not defined', -924, 335544325)
When I use ISO88591, the connect works, but Python is not happy with that:
Traceback (most recent call last):
File "sync.py", line 10, in <module>
conn = fdb.connect(dsn=local_copy, user='***', password='***', charset="ANSI")
File "/usr/local/lib/python3.6/site-packages/fdb/fbcore.py", line 826, in connect
no_reserve, db_key_scope, no_gc, no_db_triggers, no_linger)
File "/usr/local/lib/python3.6/site-packages/fdb/fbcore.py", line 759, in build_dpb
dpb.add_string_parameter(isc_dpb_user_name, user)
File "/usr/local/lib/python3.6/site-packages/fdb/fbcore.py", line 624, in add_string_parameter
value = value.encode(charset_map.get(self.charset, self.charset))
LookupError: unknown encoding: ISO88591
So, I thought perhaps adding an alias ISO88591 to Python would work. I tried to edit the /usr/lib64/python3.6/encodings/aliases.py, but that didn't seem to have any effect.
As a short summary of what was posted on Firebird-support, it looks the fbintl module in Firebird 2.5.8 on CentOS is broken.
As indicated by Philippe Makowski:
Sorry, it is broken, and I don't know how to fix it :
https://bugzilla.redhat.com/show_bug.cgi?id=1636177
but Firebird 3 is ok
https://copr.fedorainfracloud.org/coprs/makowski/firebird/
A possible workaround suggested in https://bugzilla.redhat.com/show_bug.cgi?id=1636177 is to either downgrade to 2.5.7, or to continue using 2.5.8, but replace its fbintl module with the one from 2.5.7.

Adding Xilinx AXI DMA core to block design cause Xilinx SDK error

After adding Xilinx AXI DMA IP Core to Block design (Vivado IP Integrator, Zynq), hardware specification, generated by Vivado become not processable by Xilinx SDK.
AXI DMA has simple configuration, read channel only, no Scatter/Gather.
Vivado 2014.1 / Xilinx SDK 2014.1
ERROR : [Common 17-55] 'get_property' expects at least one object.
ERROR: [Hsm 55-1545] Problem running tcl command ::sw_petalinux_v2_00_b::generate : ERROR: [Common 17-55] 'get_property' expects at least one object.
while executing
"get_property NAME $axidma_ip_handle"
("axi_dma" arm line 8)
invoked from within
"switch -exact $type {
"axi_intc" {
# Interrupt controllers
lappend node [gen_intc $slave $intc "interrupt-controller" "C_NUM_INTR_INPUTS C_KIN..."
(procedure "gener_slave" line 37)
invoked from within
"gener_slave $bus_node $ip $intc_handle "" $busif_handle"
("foreach" body line 17)
invoked from within
"foreach ip $sorted_ip {
# make sure the sorted_ip list does not content force ip list
# otherwise, same duplication of dts node will appeare..."
(procedure "bus_bridge" line 153)
invoked from within
"bus_bridge $hwproc_handle $intc 0 "M_AXI_DP" "" $ips "ps7_pl310 ps7_xadc""
(procedure "generate_device_tree" line 93)
invoked from within
"generate_device_tree "xilinx.dts" $bootargs $consoleip"
(procedure "device-tree_v1_01_b::generate" line 53)
invoked from within
"${bsp}::generate $os_handle"
(procedure "namespace_generate" line 6)
invoked from within
"namespace_generate $bsp $bsp $path $os_handle"
("foreach" body line 3)
invoked from within
"foreach bsp ${bsps} {
create_namespace $path $bsp $os_handle
namespace_generate $bsp $bsp $path $os_handle
}"
(procedure "::sw_petalinux_v2_00_b::generate" line 16)
invoked from within
"::sw_petalinux_v2_00_b::generate petalinux"
ERROR: [Hsm 55-1442] Error(s) while running TCL procedure generate()
ERROR : Error generating bsp sources: Failed to generate BSP.
But without AXI DMA, the ARM+FPGA project works well.

PyBBIO Analog Input: Failure to Load ADC File

While running the PyBBIO examples phant_test.py and analog_test.py I received the following error (I believe 'could' is a typo meant to be 'could not'):
Traceback (most recent call last):
File "analog_test.py", line 47, in <module>
run(setup, loop)
File "/usr/lib/python2.7/site-packages/PyBBIO-0.9-py2.7-linux-armv7l.egg/bbio/bbio.py", line 63, in run
loop()
File "analog_test.py", line 37, in loop
val1 = analogRead(pot1)
File "/usr/lib/python2.7/site-packages/PyBBIO-0.9-py2.7-linux-armv7l.egg/bbio/platform/beaglebone/bone_3_8/adc.py", line 46, in analogRead
raise Exception('*Could load overlay for adc_pin: %s' % adc_pin)
Exception: *Could load overlay for adc_pin: ['/sys/devices/ocp.2/PyBBIO-AIN0.*/AIN0', 'PyBBIO-AIN0', 'P9.39']
I have tried restarting the BeagleBone (rev A6 running Angstrom with a 3.8 kernel, with no capes connected) to clear the /sys/devices/bone_capemgr.7/slots file, but that did not work. It seems PyBBIO is accessing the slots file and adding overlays because the slots file looks like this after the example program runs:
0: 54:PF---
1: 55:PF---
2: 56:PF---
3: 57:PF---
4: ff:P-O-L Override Board Name,00A0,Override Manuf,PyBBIO-ADC
5: ff:P-O-L Override Board Name,00A0,Override Manuf,PyBBIO-AIN0
Since there were some changes being made to the slots file I checked what files the analog_read(adc_pin) function in the adc.py file of PyBBIO was retrieving. With some print statements I figured out the root problem was that the /sys/devices/ocp.2/PyBBIO-AIN0.*/AIN0 file, which apparently stores the analog read values, does not exist. The glob.glob function returns a null array, and ls /sys/devices/ocp.2/PyBBIO-AIN0.10/ shows modalias power subsystem uevent as the only contents. Is there something wrong in the overlay file? Or could there be another program or problem that is preventing the BeagleBone from writing the AIN0 file that PyBBIO is trying to read? The python code seems to be logically correct, but the overlay is working incorrectly or being blocked in some way.

Resources