snprintf(buf,BUFSIZE,"G %d A\r\n",lpc->roff);
len=strlen(buf);
- ret=txrx(lpc,buf,ret,TXRX_TYPE_CMD);
+ ret=txrx(lpc,buf,len,TXRX_TYPE_CMD);
return ret;
}
}
/* make it a multiple of 3 (reason: uuencode) */
- nlen=(len/3+1)*3;
+ nlen=(!(len%3))?len:((len/3+1)*3);
if(nlen>BUFSIZE) {
printf("ram write: too much data\n");
return -1;
while(bcnt<nlen) {
/* uuencode / prepare data bytes */
- uuencode((u8 *)(buf+bcnt),(u8 *)(txrxbuf),bcnt==nlen-3?len%3:3);
+ uuencode((u8 *)(buf+bcnt),(u8 *)(txrxbuf),
+ (bcnt==nlen-3)?(len%3?len%3:3):3);
txrxbuf[5]='\r';
txrxbuf[6]='\n';
checksum+=((u8)buf[bcnt]+(u8)buf[bcnt+1]+(u8)buf[bcnt+2]);
/* send a data line */
- txrx(lpc,txrxbuf,6,TXRX_TYPE_DATA);
+ txrx(lpc,txrxbuf,7,TXRX_TYPE_DATA);
/* increase counters */
lcount+=1;
firmware_to_ram(&lpc);
/* unlock go cmd */
+ printf("unlock go command ...\n");
unlock_go(&lpc);
/* go! */
+ printf("go ...\n");
go(&lpc);
+ printf("\n");
end:
close(lpc.sfd);