Hello,
I bought pixy about a month ago and I am trying to hook up pixy1 to raspberry pi2 since then. I followed the tutorial. I am calling hello pixy with sudo.
sudo ./hello_pixy
Here is the output (I am receiving empty frames):
Hello Pixy:
libpixyusb Version: 0.4
Pixy Firmware Version: 2.0.19
Detecting blocks...
frame 0:
frame 1:
frame 2:
I started to debug the code and figure out the following:
- pixy_get_blocks in hello_pixy.cpp always returns 0.
- I recompiled the usb library with debug option on and added a few log entries. (check at the end of this post for git diff)
./build_libpixyusb.sh debug
- via this method I then tracked where 0 is coming from.
- I figured out that pixyinterpreter.cpp function PixyInterpreter::interpret_CCB2, number_of_blobs variable is always equal to 0. Because received data CCB2_data[3] is always 0.
number_of_blobs = * static_cast<const uint32_t *>(CCB2_data[3]);
- From bellow log it seems that I am getting a valid frame from pixy, but data at CCB2_data[3] is 0.
Would appreciate if anyone can help me out, because I’ve been stuck on this issue for quite a while. Are libpixyusb Version: 0.4 and Pixy Firmware Version: 2.0.19 compatible?
Here is the log:
Hello Pixy:
libpixyusb Version: 0.4
pixydebug: USBLink::open()
pixydebug: libusb_init() = 0
pixydebug: libusb_open_device_with_vid_pid() = 35517168
pixydebug: libusb_set_configuration() = 0
pixydebug: libusb_claim_interface() = 0
pixydebug: libusb_reset_device() = 0
pixydebug: USBLink::open() returned 0
pixydebug: Chirp::Chirp()
pixydebug: Chirp::Chirp() returned
pixydebug: Chirp::setLink()
pixydebug: USBLink::send()
pixydebug: USBLink::send() returned 64
pixydebug: USBLink::receive()
pixydebug: libusb_bulk_transfer(64 bytes) = 0
pixydebug: USBLink::receive() returned 64 (bytes transferred)
pixydebug: remoteInit() = 0
pixydebug: setLink() returned 0
pixydebug: USBLink::send()
pixydebug: USBLink::send() returned 64
pixydebug: USBLink::receive()
pixydebug: libusb_bulk_transfer(64 bytes) = 0
pixydebug: USBLink::receive() returned 64 (bytes transferred)
pixydebug: USBLink::send()
pixydebug: USBLink::send() returned 64
pixydebug: USBLink::receive()
pixydebug: libusb_bulk_transfer(64 bytes) = 0
pixydebug: USBLink::receive() returned 64 (bytes transferred)
Pixy Firmware Version: 2.0.19
Detecting blocks...
pixydebug: USBLink::receive()
pixydebug: libusb_bulk_transfer(64 bytes) = 0
pixydebug: USBLink::receive() returned 64 (bytes transferred)
pixydebug: PixyInterpreter::interpret_CCB2()
pixydebug: *CCB2_data[0] = 0x40424201
pixydebug: *CCB2_data[1] = 0x42420140
pixydebug: *CCB2_data[2] = 0x828200c8
pixydebug: *CCB2_data[3] = 0x0
pixydebug: *CCB2_data[4] = 0x82000082
pixydebug: *CCB2_data[5] = 0x0
pixydebug: *CCB2_data[6] = 0x0
pixydebug: number_of_blobs = 0
pixydebug: PixyInterpreter::add_normal_blocks()
pixydebug: count = 0
frame 0:
pixydebug: USBLink::receive()
pixydebug: libusb_bulk_transfer(64 bytes) = 0
pixydebug: USBLink::receive() returned 64 (bytes transferred)
pixydebug: PixyInterpreter::interpret_CCB2()
pixydebug: *CCB2_data[0] = 0x40424201
pixydebug: *CCB2_data[1] = 0x42420140
pixydebug: *CCB2_data[2] = 0x828200c8
pixydebug: *CCB2_data[3] = 0x0
pixydebug: *CCB2_data[4] = 0x82000082
pixydebug: *CCB2_data[5] = 0x0
pixydebug: *CCB2_data[6] = 0x0
pixydebug: number_of_blobs = 0
pixydebug: PixyInterpreter::add_normal_blocks()
pixydebug: count = 0
Changes I made to the code:
diff --git a/src/host/libpixyusb/src/pixyinterpreter.cpp b/src/host/libpixyusb/src/pixyinterpreter.cpp
index 8ca963f..116b862 100644
--- a/src/host/libpixyusb/src/pixyinterpreter.cpp
+++ b/src/host/libpixyusb/src/pixyinterpreter.cpp
@@ -16,6 +16,7 @@
#include <string.h>
#include <stdio.h>
#include "pixyinterpreter.hpp"
+#include "debuglog.h"
PixyInterpreter::PixyInterpreter()
{
@@ -244,6 +245,13 @@ void PixyInterpreter::interpret_CCB2(const void * CCB2_data[])
const BlobB * B_blobs;
uint32_t index;
+ log("pixydebug: PixyInterpreter::interpret_CCB2()\n");
+
+ for (index = 0; index < 7; index++)
+ {
+ log("pixydebug: *CCB2_data[%d] = 0x%x\n", index, * static_cast<const uint32_t *>(CCB2_data[index]));
+ }
+
// Wait for permission to use blocks_ vector //
blocks_access_mutex_.lock();
@@ -266,6 +274,8 @@ void PixyInterpreter::interpret_CCB2(const void * CCB2_data[])
number_of_blobs /= sizeof(BlobA) / sizeof(uint16_t);
+ log("pixydebug: number_of_blobs = %d\n", number_of_blobs);
+
add_normal_blocks(A_blobs, number_of_blobs);
blocks_are_new_ = true;
blocks_access_mutex_.unlock();
@@ -276,6 +286,9 @@ void PixyInterpreter::add_normal_blocks(const BlobA * blocks, uint32_t count)
uint32_t index;
Block block;
+ log("pixydebug: PixyInterpreter::add_normal_blocks()\n");
+ log("pixydebug: count = %d\n", count);
+
for (index = 0; index != count; ++index) {
// Decode CCB1 'Normal' Signature Type //
git log -1:
commit 6e8c33cea264ad063800fe0424e3509873e8be51
Date: Fri May 25 17:04:06 2018 -0500
...