This program is fantastic! Thank you!
I did have some trouble trying to upload a large file (10360862 bytes), and it crashed with a segfault. I think the problem was that Sendbuf was too large to be on the stack. At any rate, this patch seems to have fixed the issue.
diff -r p2kc/p2k-core/p2k-core.c p2kc.orig/p2k-core/p2k-core.c
1394,1396c1394,1395
< const int chunksize=0x400;
< int bytes_done=0,i=0,k=0,thisChunkSize,numchunks;
< unsigned char Sendbuf[chunksize+16];
---
> int bytes_done=0,chunksize=0x400,i=0,k=0,numchunks;
> unsigned char Sendbuf[size+16];
1414,1420c1413,1418
< thisChunkSize = chunksize;
< if (size-bytes_done<0x400) thisChunkSize=size-bytes_done;
< setInt16(Sendbuf+4,thisChunkSize+8); // argsize (extra bytes)
< setInt32(Sendbuf+12,thisChunkSize); // extra bytes (cmd args)
< memcpy(Sendbuf+16,buffer+bytes_done,thisChunkSize);
< if (P2k_SendCommand (hdev,Sendbuf,thisChunkSize+16,Recbuf)==-1) return 0;
< bytes_done=bytes_done+thisChunkSize;i=i+1;
---
> if (size-bytes_done<0x400) chunksize=size-bytes_done;
> setInt16(Sendbuf+4,chunksize+8); // argsize (extra bytes)
> setInt32(Sendbuf+12,chunksize); // extra bytes (cmd args)
> memcpy(Sendbuf+16,buffer+bytes_done,chunksize);
> if (P2k_SendCommand (hdev,Sendbuf,chunksize+16,Recbuf)==-1) return 0;
> bytes_done=bytes_done+chunksize;i=i+1;
Hope this helps. Keep up the great work!