Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data Loss #47

Open
realJoshByrnes opened this issue Mar 18, 2023 · 7 comments
Open

Data Loss #47

realJoshByrnes opened this issue Mar 18, 2023 · 7 comments

Comments

@realJoshByrnes
Copy link
Collaborator

realJoshByrnes commented Mar 18, 2023

When trying to sniff, it seems like data is disappearing and out of sync... I thought it was just my code, but it happens on yours, too.

Here we have 0x01 (Controller) 0x42 (Status)
We get a reply of 0xff, 0x73 (Device ID: 0x7 - DS Analog, Length: 0x3 UInt16s), 0x5a (Header End) - Perfect.
For the data section, we get 0xffff66 - expect something like 0xffff6661647b (as received second time)

0142000000 0142000000000000 0142000000...
ff735affff66 ff735affff6661647b ff735a...
    01      ff
    42      73
    00      5a
    00      ff
    00      ff
    01      66
    42      ff
    00      73
    00      5a
    00      ff
    00      ff
    00      66
    00      61
    01      64
    42      7b
    00      ff
    00      73
    00      5a

The same thing is happening in my own code (using psxSPI.pio):

RX: 01 42 00 00 00 01 42 00 00
TX: FF 73 5A FF FF 66 FF 73 5A
RX: 00 00 00
TX: FF FF 66
RX: 01 42 00
TX: 61 61 FF
RX: 00 00 00
TX: 73 5A FF

Initially I thought it might be because I was using printf() in the interrupt, but it seems to be happening with your example, too. Are you able to sniff without issues?

I'm wondering if I'm doing something wrong?

@realJoshByrnes
Copy link
Collaborator Author

Just had a thought that maybe it's only Pico W
Further testing that the same happens on Pico (non-W)

@dangiu
Copy link
Owner

dangiu commented Mar 19, 2023

Did you use the sniffer example to sniff? I don't quite remember how it set it up (I added it to the repository mostly as historical material) but I remember that I was having trouble when printing during interrupts or "during capture". To get reliable output I needed to store the data received inside an array and then print it all after the execution. A sort of post-mortem analysis

@realJoshByrnes
Copy link
Collaborator Author

Yeah I tried that example, as well as my own. Submitted PR in #51 for the proof-of-concept projects.

It would be great to have the discussions tab enabled to discuss possibilities.

@dangiu
Copy link
Owner

dangiu commented Mar 19, 2023

Ok I'll look into setting it up, thanks for the quick feedback!

@realJoshByrnes
Copy link
Collaborator Author

Ok I'll look into setting it up, thanks for the quick feedback!

The issue appears to be in cmd_reader PIO program. I don't think you need the bit counter when autopush is enabled.

Using the following psxSPI.pio is in sync and works for sniffing (doesn't ACK on purpose)
https://github.com/realJoshByrnes/PicoMemcard/blob/641992ca1d0fb8ca68476bb61867e36dda61b4e5/pio/psxSPI.pio#L28

@dangiu
Copy link
Owner

dangiu commented Mar 28, 2023

The bit counter is needed in order to know when to ACK, but we can probably move the acking function to dat_writer and ACK each time we need to send something, it would probably be more logical and cleanup a lot of code.

@realJoshByrnes
Copy link
Collaborator Author

@dangiu It sounds good as long as we can choose to send the ACK (so we don't send after the last byte)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants