alttpo / sni

SNES Interface with gRPC API
MIT License
46 stars 12 forks source link

DeviceFilesystem.PutFile fails when data is not an exact multiple of 512 bytes #3

Closed HT154 closed 2 years ago

HT154 commented 2 years ago

Observed on darwin/arm64 running the darwin/amd64 executable.

Working case with 512 byte file:

dd bs=512 count=1 if=/dev/urandom of=test.dat
grpcurl -plaintext -proto ./sni.proto  -d "{\"uri\":\"fxpakpro://./dev/cu.usbmodemDEMO000000001\",\"path\":\"/test.dat\",\"data\":\"$(base64 < ./test.dat)\"}" localhost:8191 DeviceFilesystem.PutFile

This results in the expected output and the file being transferred successfully.

Here's the failing case:

dd bs=513 count=1 if=/dev/urandom of=test2.dat # any block size can be used here as long as it's not a multiple of 512
grpcurl -plaintext -proto ./sni.proto  -d "{\"uri\":\"fxpakpro://./dev/cu.usbmodemDEMO000000001\",\"path\":\"/test2.dat\",\"data\":\"$(base64 < ./test2.dat)\"}" localhost:8191 DeviceFilesystem.PutFile

This outputs

ERROR:
  Code: Unknown
  Message: fxpakpro: sendSerialProgress: read from io.Reader: EOF

And the SNI logs show

2021/12/16 08:15:59.851574 fxpakpro: open(name="/dev/cu.usbmodemDEMO000000001", baud=230400)
2021/12/16 08:15:59.876054 sendSerialProgress: something funky happened; only read 1 bytes when expecting 512
2021/12/16 08:15:59.877601        /DeviceFilesystem/PutFile:   25986833 ns: req=`uri:"fxpakpro://./dev/cu.usbmodemDEMO000000001" path:"/test2.dat" data:"<RAW DATA>"`, err=`fxpakpro: sendSerialProgress: read from io.Reader: EOF`
JamesDunne commented 2 years ago

Great report! Thanks, I'll get to work on it soon. I must've been testing with rom files that are always multiples of 512 bytes.

JamesDunne commented 2 years ago

fixed in https://github.com/alttpo/sni/releases/tag/v0.0.61