Pi AVR Programmer Hat

I have the “Pi AVR Programmer HAT” and I am trying to get it working.

Amazingly the test.py script on github is unable to run.

It had what seemed like a hundred of print errors such as:

  • SyntaxError: Missing parentheses in call to ‘print’. Did you mean print(output)?

It also had a few of these where tabs were intermixed with spaces:

  • TabError: inconsistent use of tabs and spaces in indentation

https://github.com/sparkfun/SparkFun_Pi … er/test.py

How to duplicate this problem

=========================

I loaded the OS as shown below using the current Raspberry Pi OS Imager v1.7.3

Listed as:

===============================================

Raspberry Pi OS Lite (32-bit

A Port of Debian Bullseye with no desktop environment

released 2022-09-22

During setup, I made the user “pi”

=============================

pi@raspberrypi:~ $ whoami

pi

Here is the output of hostnamectl:

====================================

pi@raspberrypi:~ $ hostnamectl

Static hostname: raspberrypi

Icon name: computer

Machine ID: b0354f4323584028be7eed191b6ec06e

Boot ID: f832095ce1124caba5ff61d36a9cade8

Operating System: Raspbian GNU/Linux 11 (bullseye)

Kernel: Linux 5.15.61-v7+

Architecture: arm

Here is my directory structure in /home/pi

===================================

pi@raspberrypi:~ $ ls -l

total 516

-rwxrwxrwx 1 pi pi 471236 Nov 22 17:50 avrdude_gpio.conf

-rwxrwxrwx 1 pi pi 8536 Nov 22 18:00 blink.hex

-rwxrwxrwx 1 pi pi 310 Nov 22 17:53 disable_switch.py

-rwxrwxrwx 1 pi pi 310 Nov 22 17:53 enable_switch.py

-rwxrwxrwx 1 pi pi 1432 Nov 22 17:52 optiboot.hex

-rwxrwxrwx 1 pi pi 1259 Nov 22 17:51 pi_program.sh

-rwxrwxrwx 1 pi pi 18725 Nov 22 17:49 test.py

drwxr-xr-x 12 root root 4096 Nov 22 17:43 WiringPi

And here is what happens when I try to launch test.py

============================================

pi@raspberrypi:~ $ sudo python test.py

File “/home/pi/test.py”, line 128

print output

^

SyntaxError: Missing parentheses in call to ‘print’. Did you mean print(output)?

If I fix this single error by adding parentheses… it finds same error on MANY MANY more lines (every line that contains print statement.

Then it complains about:

=======================

  • TabError: inconsistent use of tabs and spaces in indentation

Loos like that program was written for python2, not python3. You could try running: ```
python2 test.py


Or convert all the print statements to print() which it sounds like you did. You can then convert the handful of tabs with spaces via

sed ‘s/\t/ /’ test.py > test-no-tabs.py


(there are exactly 8 spaces between the 2nd and 3rd slash (/) in that command)

Thank you, Yes I had already corrected all the errors as per your comment earlier…

The fixed up test.py runs in as much that the lights flash and the shutdown function works

But, here is the very strange output from when I press the capsense button:

/home/pi/optiboot.hex: 1: :107E0000112484B714BE81FFF0D085E080938100F7: not found

/home/pi/optiboot.hex: 2: :107E100082E08093C00088E18093C10086E0809377: not found

/home/pi/optiboot.hex: 3: :107E2000C20080E18093C4008EE0C9D0259A86E02C: not found

/home/pi/optiboot.hex: 4: :107E300020E33CEF91E0309385002093840096BBD3: not found

/home/pi/optiboot.hex: 5: :107E4000B09BFECF1D9AA8958150A9F7CC24DD24C4: not found

/home/pi/optiboot.hex: 6: :107E500088248394B5E0AB2EA1E19A2EF3E0BF2EE7: not found

/home/pi/optiboot.hex: 7: :107E6000A2D0813461F49FD0082FAFD0023811F036: not found

/home/pi/optiboot.hex: 8: :107E7000013811F484E001C083E08DD089C08234E0: not found

/home/pi/optiboot.hex: 9: :107E800011F484E103C0853419F485E0A6D080C0E4: not found

/home/pi/optiboot.hex: 10: :107E9000853579F488D0E82EFF2485D0082F10E0AE: not found

/home/pi/optiboot.hex: 11: :107EA000102F00270E291F29000F111F8ED06801E7: not found

/home/pi/optiboot.hex: 12: :107EB0006FC0863521F484E090D080E0DECF843638: not found

/home/pi/optiboot.hex: 13: :107EC00009F040C070D06FD0082F6DD080E0C81688: not found

/home/pi/optiboot.hex: 14: :107ED00080E7D80618F4F601B7BEE895C0E0D1E017: not found

/home/pi/optiboot.hex: 15: :107EE00062D089930C17E1F7F0E0CF16F0E7DF06D8: not found

/home/pi/optiboot.hex: 16: :107EF00018F0F601B7BEE89568D007B600FCFDCFD4: not found

/home/pi/optiboot.hex: 17: :107F0000A601A0E0B1E02C9130E011968C91119780: not found

/home/pi/optiboot.hex: 18: :107F100090E0982F8827822B932B1296FA010C0160: not found

/home/pi/optiboot.hex: 19: :107F200087BEE89511244E5F5F4FF1E0A038BF0790: not found

/home/pi/optiboot.hex: 20: :107F300051F7F601A7BEE89507B600FCFDCF97BE46: not found

/home/pi/optiboot.hex: 21: :107F4000E89526C08437B1F42ED02DD0F82E2BD052: not found

/home/pi/optiboot.hex: 22: :107F50003CD0F601EF2C8F010F5F1F4F84911BD097: not found

/home/pi/optiboot.hex: 23: :107F6000EA94F801C1F70894C11CD11CFA94CF0C13: not found

/home/pi/optiboot.hex: 24: :107F7000D11C0EC0853739F428D08EE10CD085E9AC: not found

/home/pi/optiboot.hex: 25: :107F80000AD08FE07ACF813511F488E018D01DD067: not found

/home/pi/optiboot.hex: 26: :107F900080E101D065CF982F8091C00085FFFCCF94: not found

/home/pi/optiboot.hex: 27: :107FA0009093C60008958091C00087FFFCCF809118: not found

/home/pi/optiboot.hex: 28: :107FB000C00084FD01C0A8958091C6000895E0E648: not found

/home/pi/optiboot.hex: 29: :107FC000F0E098E1908380830895EDDF803219F02E: not found

/home/pi/optiboot.hex: 30: :107FD00088E0F5DFFFCF84E1DECF1F93182FE3DFCA: not found

/home/pi/optiboot.hex: 31: :107FE0001150E9F7F2DF1F91089580E0E8DFEE27F6: not found

/home/pi/optiboot.hex: 32: :047FF000FF270994CA: not found

/home/pi/optiboot.hex: 33: :027FFE00040479: not found

/home/pi/optiboot.hex: 34: :0400000300007E007B: not found

/home/pi/optiboot.hex: 35: :00000001FF: not found

b’Programming beginning…\n’

…programming done.

Also there seems to be an issue with the “linuxspi” failing on avrdude.

I googled it and found some comments about Debian Bullseye having a issues with linuxspi…

see:

https://forums.raspberrypi.com/viewtopic.php?t=330268

https://github.com/avrdudes/avrdude/issues/1107

So, this Pi AVR Programmer Hat is going to take some effort… I might have to learn something Lol!

Thanks again for your input

Ken