Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for read(buf, len) in WifiClient and Firmware #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion firmware/wifiHD/src/ard_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1195,10 +1195,14 @@ cmd_spi_state_t get_data_tcp_cmd_cb(char* recv, char* reply, void* ctx, uint16_t
cmd_spi_state_t get_databuf_tcp_cmd_cb(char* recv, char* reply, void* ctx, uint16_t* count) {

uint8_t* data;
uint16_t len;

CHECK_ARD_NETIF(recv, reply, count);

tParam* params = (tParam*)&recv[3];

GET_PARAM_NEXT(BYTE, params, _sock);
GET_PARAM_NEXT(INT, params, len);

if ((recv[3]==1)&&(recv[4]>=0)&&(recv[4]<MAX_SOCK_NUM))
{
if (getTcpData((uint8_t)recv[4], (void**)&data, &len))
Expand Down
16 changes: 15 additions & 1 deletion firmware/wifiHD/src/ard_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,23 @@ bool getTcpData(uint8_t sock, void** payload, uint16_t* len)
p = get_pBuf(sock);
if (p != NULL)
{
if (p->idx < p->len)
{
uint8_t* buf = (uint8_t*)p->data;


*payload = &buf[p->idx];
*len = min(p->len - p->idx, *len);
INFO_UTIL_VER("get:%d %p %d %d\n",p->idx, p->data, *payload, *len);
p->idx += *len;
return true;
}
else
{
*payload = p->data;
*len = p->len;
*len = 0;
return true;
}
}
return false;
}
Expand Down
5 changes: 3 additions & 2 deletions libraries/WiFi/utility/server_drv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,9 @@ bool ServerDrv::getDataBuf(uint8_t sock, uint8_t *_data, uint16_t *_dataLen)
{
WAIT_FOR_SLAVE_SELECT();
// Send Command
SpiDrv::sendCmd(GET_DATABUF_TCP_CMD, PARAM_NUMS_1);
SpiDrv::sendBuffer(&sock, sizeof(sock), LAST_PARAM);
SpiDrv::sendCmd(GET_DATABUF_TCP_CMD, PARAM_NUMS_2);
SpiDrv::sendBuffer(&sock, sizeof(sock));
SpiDrv::sendParam(*_datalen, LAST_PARAM);

//Wait the reply elaboration
SpiDrv::waitForSlaveReady();
Expand Down