kopia lustrzana https://github.com/OpenRTX/OpenRTX
Fixed issues with _read_r in MK22FN512xx libc integration code
rodzic
aad19cc41c
commit
efb235ae4e
|
@ -213,19 +213,28 @@ int _write_r(struct _reent *ptr, int fd, const void *buf, size_t cnt)
|
|||
*/
|
||||
int _read_r(struct _reent *ptr, int fd, void *buf, size_t cnt)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if(fd == STDIN_FILENO)
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
ssize_t r = vcom_readBlock(buf, cnt);
|
||||
if((r < 0) || (r == (ssize_t)(cnt))) return r;
|
||||
if((r < 0) || (r == ((ssize_t) cnt)))
|
||||
{
|
||||
ret = ((int) r);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If fd is not stdin */
|
||||
ptr->_errno = EBADF;
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
/* If fd is not stdin */
|
||||
ptr->_errno = EBADF;
|
||||
return -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int _read(int fd, void *buf, size_t cnt)
|
||||
|
|
|
@ -649,12 +649,12 @@ ssize_t vcom_writeBlock(const void *buf, size_t len)
|
|||
|
||||
ssize_t vcom_readBlock(void* buf, size_t len)
|
||||
{
|
||||
if((cdcVcom.attach == 1) && (cdcVcom.startTransactions == 1))
|
||||
if(recvSize != 0)
|
||||
{
|
||||
size_t toTransfer = (len < recvSize) ? len : recvSize;
|
||||
memcpy(buf, recvBuf, toTransfer);
|
||||
recvSize = 0;
|
||||
return toTransfer;
|
||||
return ((ssize_t) toTransfer);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Ładowanie…
Reference in New Issue