ShendoXT / memcarduino

Arduino PlayStation 1 Memory Card reader
GNU General Public License v3.0
258 stars 39 forks source link

A python error occurred when bad checksum. #11

Closed tosik closed 3 years ago

tosik commented 6 years ago

I would like to report an error.

https://github.com/ShendoXT/memcarduino/blob/master/memcarduino.py#L195

This line has an undefined variable res.

Traceback (most recent call last):
  File "memcarduino.py", line 341, in <module>
    memcard_write(f)
  File "memcarduino.py", line 195, in memcard_write
    print "BAD CHECKSUM at frame "+str(i+1)+"/"+str(end)+"  Address:"+ByteToHex(hex_data)+"  CHECKSUM:"+ByteToHex(chk)+" TimeTaken:"+str(tPrint)+str(res)
TheBlueTroll commented 6 years ago

I see, sorry i guess i haven't throughly tested the writing code, but a bad checksum means that the memory card thinks the data sent doesnt match what should have been sent (we dont calculate the checksum, just write the data) and its up to the game to retry writing the data. However as you can see, the script just ignores it and would continue. When i have time later today i will fix the error (more then likely just remove the str (res) as its not clear what i was using that for) and test it just to be sure.

TheBlueTroll commented 6 years ago

soo on closer inspection, ive already fixed this bug on my fork, and havent issued a pull request since. soo maby head over to https://github.com/TheBlueTroll/memcarduino while i sort out the pull request.

tosik commented 6 years ago

Thank you so much!

tosik commented 6 years ago

Is this line https://github.com/TheBlueTroll/memcarduino/blob/master/memcarduino.py#L287 the fix? i will try to use your forked version.

TheBlueTroll commented 6 years ago

sure, if you are still having issues be sure to double and triple check that the connections are correct as a bad checksum on writing is not a normal thing, and it happening usually means the memory card is not getting the data OR that the data is corrupt to begin with. it can additionaly mean not enough power on the 3.6 causing the memorycard to become unhappy.

tosik commented 6 years ago

I added sleep in each writing loop then no checksum error occurs. Maybe it is my device problem.

TheBlueTroll commented 6 years ago

thats...unexpected. usually writes only go as fast as the memcard would allow, or assume a rather slow rate via time outs, where did you add the delays for writing? as i am not sure how that actually results in solving the problem.

In addition, i've fixed another bug i hadn't noticed in relation to the checksumming that may have been the cause all along. ive updated mine again and will begin some more testing to confirm everything works right.