STM32F767 ethernet rychlost
Jaroslav Buchta
jaroslav.buchta na hascomp.cz
Sobota Říjen 7 11:31:35 CEST 2017
Zdravim,
mam problem s implementaci subj, pouziva HAL, vse nakonfigurovano
pokusne v prazdnem projektu.
Aplikace pouze odesila data po pripojeni klienta, prenosova rychlost je
zoufala, asi 1kB/s.... Netusi nekdo, v cem muze byt problem? Asi malo
nejakych bufferu? Ale experimenty nikam nevedly.
Pres switch to chodi asi 3x rychleji nez primo pripojene k PC, asi to
servisni komunikace nejak zahlti? Nebo delam neco spatne?
Sledovana komunikace ale vypada plynula bez komplikaci, .123 je PC, .9
STM, viz priloha
Vypis dulezite casti programu:
/* USER CODE BEGIN 4 */
static err_t echo_accept(void *arg, struct tcp_pcb *pcb, err_t err);
static err_t echo_recvd(void * arg, struct tcp_pcb * tpcb, struct pbuf *
p, err_t err);
static err_t echo_sent(void * arg, struct tcp_pcb * tpcb, u16_t len);
static void echo_err(void * arg, err_t err);
static struct tcp_pcb *pcbListened = NULL;
static struct tcp_pcb *pcbAccepted = NULL;
static int connCount;
static osSemaphoreId transferSemphHandle = NULL;
static err_t echo_accept(void *arg, struct tcp_pcb *pcb, err_t err)
{
LWIP_UNUSED_ARG(arg);
LWIP_UNUSED_ARG(err);
if (pcbListened == NULL) return ERR_ARG;
if (connCount >= 1)
{
tcp_abort(pcb);
return ERR_ABRT;
}
connCount++;
tcp_arg(pcb, NULL);
tcp_recv(pcb, echo_recvd);
tcp_sent(pcb, echo_sent);
tcp_err(pcb, echo_err);
// tcp_setprio(pcb, TCP_PRIO_MIN);
tcp_accepted(pcbListened);
pcbAccepted = pcb;
return ERR_OK;
}
static err_t echo_recvd(void * arg, struct tcp_pcb * tpcb, struct pbuf *
p, err_t err)
{
if (p == NULL)
{ // EOF signal, connection closed
tcp_close(tpcb);
pcbAccepted = NULL;
connCount--;
if (arg != NULL)
{
// mbsDescFree((MBS_Descriptor *)arg);
}
}
else
{
tcp_recved(tpcb, p->tot_len);
// DBGUSART_Format("MBS-> Received %08x, %d B"DBGSTRNL,
(uint32_t)tpcb, p->tot_len);
uint8_t *pd = (uint8_t *)p->payload;
uint16_t len = p->len;
uint8_t exc = 0;
if (p != NULL) pbuf_free(p);
}
return ERR_OK;
}
uint8_t bufSend[1024];
uint8_t sendPcs = 0;
static err_t echo_sent(void * arg, struct tcp_pcb * tpcb, u16_t len)
{
osSemaphoreRelease(transferSemphHandle);
//TerminalFormatNl("MBS-> Sent %08x, %d B", (uint32_t)tpcb,
(uint32_t)len);
//osMutexRelease(transferMutexHandle);
HAL_GPIO_WritePin(LD3_GPIO_Port, LD3_Pin, GPIO_PIN_RESET);
return ERR_OK;
}
static void echo_err(void * arg, err_t err)
{
}
/* USER CODE END 4 */
/* StartDefaultTask function */
void StartDefaultTask(void const * argument)
{
/* init code for LWIP */
MX_LWIP_Init();
/* USER CODE BEGIN 5 */
osSemaphoreDef(transferSemph);
transferSemphHandle = osSemaphoreCreate(osSemaphore(transferSemph), 1);
struct tcp_pcb *pcb = tcp_new();
if (pcb == NULL) Error_Handler();
err_t err = tcp_bind(pcb, IP_ADDR_ANY, 52222);
if (err != ERR_OK) Error_Handler();
pcb = tcp_listen(pcb);
if (pcb == NULL) Error_Handler();
tcp_accept(pcb, echo_accept);
pcbListened = pcb;
uint32_t tckLed = 0;
/* Infinite loop */
for(;;)
{
uint32_t tck = osKernelSysTick();
if (tck-tckLed>250)
{
tckLed = tck;
HAL_GPIO_TogglePin(LD2_GPIO_Port, LD2_Pin);
}
osSemaphoreWait(transferSemphHandle, 50);
if (connCount != 0)
{
err_t e = tcp_write(pcbAccepted, bufSend, sizeof(bufSend),
TCP_WRITE_FLAG_MORE);
if (e == ERR_OK)
{
HAL_GPIO_WritePin(LD3_GPIO_Port, LD3_Pin, GPIO_PIN_SET);
}
else
{
}
}
}
/* USER CODE END 5 */
}
------------- další část ---------------
A non-text attachment was scrubbed...
Name: Stmeth2.zip
Type: application/x-zip-compressed
Size: 2178 bytes
Desc: [žádný popis není k dispozici]
URL: <http://list.hw.cz/pipermail/hw-list/attachments/20171007/8ae1ba58/attachment.bin>
Další informace o konferenci Hw-list