|
@@ -38,9 +38,9 @@ SOFTWARE.
|
|
|
/******************************************************************************
|
|
/******************************************************************************
|
|
|
* Enumerations, structures & Variables
|
|
* Enumerations, structures & Variables
|
|
|
******************************************************************************/
|
|
******************************************************************************/
|
|
|
-#define DEBUG_LOG_EN 1
|
|
|
|
|
-#define LOG_D DLOG_I
|
|
|
|
|
-#define LOG_E DLOG_I
|
|
|
|
|
|
|
+
|
|
|
|
|
+#define LOG_I(...) do{if(0){printf("[%s][%d]:", __FUNCTION__, __LINE__);printf(__VA_ARGS__);printf("\r\n");}}while(0)
|
|
|
|
|
+
|
|
|
/* Structs used by the service to inform the user(upper layer) of an event */
|
|
/* Structs used by the service to inform the user(upper layer) of an event */
|
|
|
static n_indn_t sgn_indn,sf_indn;
|
|
static n_indn_t sgn_indn,sf_indn;
|
|
|
static n_ff_indn_t sgn_ff_indn;
|
|
static n_ff_indn_t sgn_ff_indn;
|
|
@@ -141,7 +141,7 @@ inline static uint8_t n_get_dt_offset(addr_md address, pci_type pci, uint16_t da
|
|
|
addr_mode = N_ADM_EXTENDED;
|
|
addr_mode = N_ADM_EXTENDED;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- uint8_t offset = (addr_mode & 0x01); //????1.
|
|
|
|
|
|
|
+ uint8_t offset = (addr_mode & 0x01);
|
|
|
|
|
|
|
|
switch (pci)
|
|
switch (pci)
|
|
|
{
|
|
{
|
|
@@ -222,9 +222,7 @@ inline static n_rslt n_pci_pack(addr_md mode, n_pdu_t* n_pdu, const uint8_t* dt)
|
|
|
{
|
|
{
|
|
|
addr_mode = N_ADM_EXTENDED;
|
|
addr_mode = N_ADM_EXTENDED;
|
|
|
}
|
|
}
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("addr_mode:0x%x", addr_mode);
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("addr_mode:0x%x", addr_mode);
|
|
|
uint8_t offs = (addr_mode & 0x01);
|
|
uint8_t offs = (addr_mode & 0x01);
|
|
|
|
|
|
|
|
switch (n_pdu->n_pci.pt)
|
|
switch (n_pdu->n_pci.pt)
|
|
@@ -279,55 +277,45 @@ inline static n_rslt n_pci_unpack(addr_md mode, n_pdu_t* n_pdu, uint8_t dlc, ui
|
|
|
{
|
|
{
|
|
|
addr_mode = N_ADM_EXTENDED;
|
|
addr_mode = N_ADM_EXTENDED;
|
|
|
}
|
|
}
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("dlc:%d,data:", dlc);
|
|
|
|
|
- for(int i=0; i<dlc; i++)
|
|
|
|
|
- {
|
|
|
|
|
- printf("%02X", dt[i]);
|
|
|
|
|
- }
|
|
|
|
|
- printf("\r\n");
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // printf("[%s:%d],dlc:%d,data:", __FUNCTION__, __LINE__, dlc);
|
|
|
|
|
+ // for(int i=0; i<dlc; i++)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // printf("%02X", dt[i]);
|
|
|
|
|
+ // }
|
|
|
|
|
+ // printf("\r\n");
|
|
|
|
|
+
|
|
|
if (n_pdu != NULL && dt != NULL)
|
|
if (n_pdu != NULL && dt != NULL)
|
|
|
{
|
|
{
|
|
|
uint8_t offs = (addr_mode & 0x01); //????1.
|
|
uint8_t offs = (addr_mode & 0x01); //????1.
|
|
|
n_pdu->n_pci.pt = (pci_type)((dt[0 + offs] & 0xF0) >> 4); //?§Ø????????????
|
|
n_pdu->n_pci.pt = (pci_type)((dt[0 + offs] & 0xF0) >> 4); //?§Ø????????????
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("n_pdu->n_pci.pt:0x%x", n_pdu->n_pci.pt);
|
|
|
|
|
-#endif
|
|
|
|
|
|
|
+ LOG_I("n_pdu->n_pci.pt:0x%x", n_pdu->n_pci.pt);
|
|
|
switch (n_pdu->n_pci.pt)
|
|
switch (n_pdu->n_pci.pt)
|
|
|
{
|
|
{
|
|
|
- case N_PCI_T_SF: //???
|
|
|
|
|
- n_pdu->n_pci.dl = dlc <= 8 ? (dt[0 + offs] & 0x0F) : (dt[1 + offs]); //??????????payload?????.???dlc??????????8?.?
|
|
|
|
|
|
|
+ case N_PCI_T_SF: //??
|
|
|
|
|
+ n_pdu->n_pci.dl = dlc <= 8 ? (dt[0 + offs] & 0x0F) : (dt[1 + offs]);
|
|
|
result = N_OK;
|
|
result = N_OK;
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("N_PCI_T_SF,n_pdu->n_pci.dl:%d", n_pdu->n_pci.dl);
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("N_PCI_T_SF,n_pdu->n_pci.dl:%d", n_pdu->n_pci.dl);
|
|
|
break;
|
|
break;
|
|
|
- case N_PCI_T_FF: //???
|
|
|
|
|
|
|
+ case N_PCI_T_FF: //??
|
|
|
n_pdu->n_pci.dl = (dt[0 + offs] & 0x0F) << 8 | dt[1 + offs];
|
|
n_pdu->n_pci.dl = (dt[0 + offs] & 0x0F) << 8 | dt[1 + offs];
|
|
|
n_pdu->sz = dlc - (2 + offs);
|
|
n_pdu->sz = dlc - (2 + offs);
|
|
|
result = N_OK;
|
|
result = N_OK;
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("N_PCI_T_FF,n_pdu->n_pci.dl:%d,n_pdu->sz:%d", n_pdu->n_pci.dl, n_pdu->sz);
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("N_PCI_T_FF,n_pdu->n_pci.dl:%d,n_pdu->sz:%d", n_pdu->n_pci.dl, n_pdu->sz);
|
|
|
break;
|
|
break;
|
|
|
- case N_PCI_T_FC: //?????
|
|
|
|
|
|
|
+ case N_PCI_T_FC: //???
|
|
|
n_pdu->n_pci.fs = dt[0 + offs] & 0x0F;
|
|
n_pdu->n_pci.fs = dt[0 + offs] & 0x0F;
|
|
|
n_pdu->n_pci.bs = dt[1 + offs];
|
|
n_pdu->n_pci.bs = dt[1 + offs];
|
|
|
n_pdu->n_pci.st = dt[2 + offs];
|
|
n_pdu->n_pci.st = dt[2 + offs];
|
|
|
n_pdu->sz = dlc - (2 + offs);
|
|
n_pdu->sz = dlc - (2 + offs);
|
|
|
result = N_OK;
|
|
result = N_OK;
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("N_PCI_T_FF,n_pdu->n_pci.fs:%d,n_pdu->n_pci.bs:%d,n_pdu->n_pci.st:%d,n_pdu->sz:%d", n_pdu->n_pci.fs,n_pdu->n_pci.bs,n_pdu->n_pci.st,n_pdu->sz);
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("N_PCI_T_FC,n_pdu->n_pci.fs:%d,n_pdu->n_pci.bs:%d,n_pdu->n_pci.st:%d,n_pdu->sz:%d", n_pdu->n_pci.fs,n_pdu->n_pci.bs,n_pdu->n_pci.st,n_pdu->sz);
|
|
|
break;
|
|
break;
|
|
|
- case N_PCI_T_CF: //?????
|
|
|
|
|
|
|
+ case N_PCI_T_CF: //???
|
|
|
n_pdu->n_pci.sn = (dt[0 + offs] & 0x0F);
|
|
n_pdu->n_pci.sn = (dt[0 + offs] & 0x0F);
|
|
|
n_pdu->sz = dlc - (1 + offs);
|
|
n_pdu->sz = dlc - (1 + offs);
|
|
|
result = N_OK;
|
|
result = N_OK;
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("N_PCI_T_CF,n_pdu->n_pci.sn:%d,n_pdu->sz:%d", n_pdu->n_pci.sn, n_pdu->sz);
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("N_PCI_T_CF,n_pdu->n_pci.sn:%d,n_pdu->sz:%d", n_pdu->n_pci.sn, n_pdu->sz);
|
|
|
break;
|
|
break;
|
|
|
default:
|
|
default:
|
|
|
result = N_ERROR;
|
|
result = N_ERROR;
|
|
@@ -392,30 +380,22 @@ inline static n_rslt n_pdu_unpack_dt(addr_md mode, n_pdu_t* n_pdu, uint8_t* dt)
|
|
|
switch (n_pdu->n_pci.pt)
|
|
switch (n_pdu->n_pci.pt)
|
|
|
{
|
|
{
|
|
|
case N_PCI_T_SF:
|
|
case N_PCI_T_SF:
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("copy N_PCI_T_SF data, len:%d", n_pdu->n_pci.dl);
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("copy N_PCI_T_SF data, len:%d", n_pdu->n_pci.dl);
|
|
|
memmove(n_pdu->sf_dt, &dt[n_get_dt_offset(addr_mode, N_PCI_T_SF, n_pdu->n_pci.dl)], n_pdu->n_pci.dl);
|
|
memmove(n_pdu->sf_dt, &dt[n_get_dt_offset(addr_mode, N_PCI_T_SF, n_pdu->n_pci.dl)], n_pdu->n_pci.dl);
|
|
|
result = N_OK;
|
|
result = N_OK;
|
|
|
break;
|
|
break;
|
|
|
case N_PCI_T_FF:
|
|
case N_PCI_T_FF:
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("copy N_PCI_T_FF data, len:%d", n_pdu->sz);
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("copy N_PCI_T_FF data, len:%d", n_pdu->sz);
|
|
|
memmove(n_pdu->dt, &dt[n_get_dt_offset(addr_mode, N_PCI_T_FF, n_pdu->sz)], n_pdu->sz);
|
|
memmove(n_pdu->dt, &dt[n_get_dt_offset(addr_mode, N_PCI_T_FF, n_pdu->sz)], n_pdu->sz);
|
|
|
result = N_OK;
|
|
result = N_OK;
|
|
|
break;
|
|
break;
|
|
|
case N_PCI_T_CF:
|
|
case N_PCI_T_CF:
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("copy N_PCI_T_CF data, len:%d", n_pdu->sz);
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("copy N_PCI_T_CF data, len:%d", n_pdu->sz);
|
|
|
memmove(n_pdu->dt, &dt[n_get_dt_offset(addr_mode, N_PCI_T_CF, n_pdu->sz)], n_pdu->sz);
|
|
memmove(n_pdu->dt, &dt[n_get_dt_offset(addr_mode, N_PCI_T_CF, n_pdu->sz)], n_pdu->sz);
|
|
|
result = N_OK;
|
|
result = N_OK;
|
|
|
break;
|
|
break;
|
|
|
case N_PCI_T_FC:
|
|
case N_PCI_T_FC:
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("copy N_PCI_T_FC data, len:%d", n_pdu->sz);
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("copy N_PCI_T_FC data, len:%d", n_pdu->sz);
|
|
|
memmove(n_pdu->dt, &dt[n_get_dt_offset(addr_mode, N_PCI_T_FC, n_pdu->sz)], n_pdu->sz);
|
|
memmove(n_pdu->dt, &dt[n_get_dt_offset(addr_mode, N_PCI_T_FC, n_pdu->sz)], n_pdu->sz);
|
|
|
result = N_OK;
|
|
result = N_OK;
|
|
|
break;
|
|
break;
|
|
@@ -436,9 +416,7 @@ inline static n_rslt n_pdu_pack(addr_md mode, n_pdu_t* n_pdu, uint32_t* id, uint
|
|
|
{
|
|
{
|
|
|
return N_ERROR;
|
|
return N_ERROR;
|
|
|
}
|
|
}
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("pack_mode:0x%x", mode);
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("pack_mode:0x%x", mode);
|
|
|
switch (mode)
|
|
switch (mode)
|
|
|
{
|
|
{
|
|
|
case N_ADM_EXTENDED:
|
|
case N_ADM_EXTENDED:
|
|
@@ -474,9 +452,7 @@ inline static n_rslt n_pdu_pack(addr_md mode, n_pdu_t* n_pdu, uint32_t* id, uint
|
|
|
case N_ADM_BMW:
|
|
case N_ADM_BMW:
|
|
|
*id = (n_pdu->n_ai.n_pr << 8) + n_pdu->n_ai.n_sa;
|
|
*id = (n_pdu->n_ai.n_pr << 8) + n_pdu->n_ai.n_sa;
|
|
|
n_pdu->dt[0] = n_pdu->n_ai.n_ta;
|
|
n_pdu->dt[0] = n_pdu->n_ai.n_ta;
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("*id:0x%x,n_pdu->dt[0]:0x%x", *id,n_pdu->dt[0]);
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("*id:0x%x,n_pdu->dt[0]:0x%x", *id,n_pdu->dt[0]);
|
|
|
break;
|
|
break;
|
|
|
default:
|
|
default:
|
|
|
return N_ERROR;
|
|
return N_ERROR;
|
|
@@ -484,7 +460,7 @@ inline static n_rslt n_pdu_pack(addr_md mode, n_pdu_t* n_pdu, uint32_t* id, uint
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
n_pci_pack(mode, n_pdu, dt);
|
|
n_pci_pack(mode, n_pdu, dt);
|
|
|
- return n_pdu_pack_dt(mode, n_pdu, dt);
|
|
|
|
|
|
|
+ return n_pdu_pack_dt(mode, n_pdu, dt); //can frame payload pack
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -496,9 +472,7 @@ inline static n_rslt n_pdu_unpack(addr_md mode, n_pdu_t* n_pdu, uint32_t id, uin
|
|
|
{
|
|
{
|
|
|
return N_ERROR;
|
|
return N_ERROR;
|
|
|
}
|
|
}
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("n_pdu_unpack,mode:0x%x",mode);
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("n_pdu_unpack,mode:0x%x",mode);
|
|
|
addr_md addr_mode = mode;
|
|
addr_md addr_mode = mode;
|
|
|
|
|
|
|
|
switch (addr_mode)
|
|
switch (addr_mode)
|
|
@@ -537,19 +511,15 @@ inline static n_rslt n_pdu_unpack(addr_md mode, n_pdu_t* n_pdu, uint32_t id, uin
|
|
|
n_pdu->n_ai.n_sa = (uint8_t)((id >> 8) & 0xFF);
|
|
n_pdu->n_ai.n_sa = (uint8_t)((id >> 8) & 0xFF);
|
|
|
n_pdu->n_ai.n_tt = (ta_type)((id & 0x40U) >> 6 == 1 ? N_TA_T_PHY : N_TA_T_FUNC);
|
|
n_pdu->n_ai.n_tt = (ta_type)((id & 0x40U) >> 6 == 1 ? N_TA_T_PHY : N_TA_T_FUNC);
|
|
|
n_pdu->n_ai.n_ae = dt[0];
|
|
n_pdu->n_ai.n_ae = dt[0];
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("n_pr:0x%x,n_ta:0x%x,n_sa:0x%x,n_tt:0x%x,n_ae:0x%x", n_pdu->n_ai.n_pr,n_pdu->n_ai.n_ta,n_pdu->n_ai.n_sa,n_pdu->n_ai.n_tt,n_pdu->n_ai.n_ae);
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("n_pr:0x%x,n_ta:0x%x,n_sa:0x%x,n_tt:0x%x,n_ae:0x%x", n_pdu->n_ai.n_pr,n_pdu->n_ai.n_ta,n_pdu->n_ai.n_sa,n_pdu->n_ai.n_tt,n_pdu->n_ai.n_ae);
|
|
|
break;
|
|
break;
|
|
|
default:
|
|
default:
|
|
|
return N_UNE_PDU;
|
|
return N_UNE_PDU;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- n_pci_unpack(mode, n_pdu, dlc, dt); //?????????payload????.
|
|
|
|
|
- n_pdu_unpack_dt(mode, n_pdu, dt); //????????.
|
|
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("n_pdu_unpack_finish");
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ n_pci_unpack(mode, n_pdu, dlc, dt);
|
|
|
|
|
+ n_pdu_unpack_dt(mode, n_pdu, dt);
|
|
|
|
|
+ LOG_I("n_pdu_unpack_finish");
|
|
|
return N_OK;
|
|
return N_OK;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -560,9 +530,7 @@ inline static n_rslt n_pdu_unpack(addr_md mode, n_pdu_t* n_pdu, uint32_t id, uin
|
|
|
*/
|
|
*/
|
|
|
inline static void signaling(signal_tp tp, n_iostream_t* strm, void(*cb)(void*), uint16_t msg_sz, n_rslt sgn_rslt)
|
|
inline static void signaling(signal_tp tp, n_iostream_t* strm, void(*cb)(void*), uint16_t msg_sz, n_rslt sgn_rslt)
|
|
|
{
|
|
{
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("tp:0x%x", tp);
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("tp:0x%x", tp);
|
|
|
if (cb != NULL)
|
|
if (cb != NULL)
|
|
|
{
|
|
{
|
|
|
switch (tp)
|
|
switch (tp)
|
|
@@ -576,10 +544,8 @@ inline static void signaling(signal_tp tp, n_iostream_t* strm, void(*cb)(void*),
|
|
|
memmove(&sgn_indn.n_pci, &strm->pdu.n_pci, sizeof(n_pci_t));
|
|
memmove(&sgn_indn.n_pci, &strm->pdu.n_pci, sizeof(n_pci_t));
|
|
|
memmove(&sgn_indn.msg, strm->msg, msg_sz);
|
|
memmove(&sgn_indn.msg, strm->msg, msg_sz);
|
|
|
strm->sts = N_S_IDLE;
|
|
strm->sts = N_S_IDLE;
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("send event to upper,N_INDN,strm->sts:0x%x", strm->sts);
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
- cb(&sgn_indn);//??????.
|
|
|
|
|
|
|
+ LOG_I("send event to upper,N_INDN,strm->sts:0x%x", strm->sts);
|
|
|
|
|
+ cb(&sgn_indn);
|
|
|
break;
|
|
break;
|
|
|
case N_SF_INDN:
|
|
case N_SF_INDN:
|
|
|
sf_indn.rslt = sgn_rslt;
|
|
sf_indn.rslt = sgn_rslt;
|
|
@@ -590,10 +556,8 @@ inline static void signaling(signal_tp tp, n_iostream_t* strm, void(*cb)(void*),
|
|
|
memmove(&sf_indn.n_pci, &strm->pdu.n_pci, sizeof(n_pci_t));
|
|
memmove(&sf_indn.n_pci, &strm->pdu.n_pci, sizeof(n_pci_t));
|
|
|
memmove(&sf_indn.sf_msg, strm->sf_msg, msg_sz);
|
|
memmove(&sf_indn.sf_msg, strm->sf_msg, msg_sz);
|
|
|
// strm->sts = N_S_IDLE;
|
|
// strm->sts = N_S_IDLE;
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("send event to upper,N_SF_INDN,strm->sts:0x%x", strm->sts);
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
- cb(&sf_indn);//??????.
|
|
|
|
|
|
|
+ LOG_I("send event to upper,N_SF_INDN,strm->sts:0x%x", strm->sts);
|
|
|
|
|
+ cb(&sf_indn);
|
|
|
break;
|
|
break;
|
|
|
case N_FF_INDN:
|
|
case N_FF_INDN:
|
|
|
sgn_ff_indn.fr_fmt = strm->fr_fmt;
|
|
sgn_ff_indn.fr_fmt = strm->fr_fmt;
|
|
@@ -602,9 +566,7 @@ inline static void signaling(signal_tp tp, n_iostream_t* strm, void(*cb)(void*),
|
|
|
memmove(&sgn_ff_indn.n_ai, &strm->pdu.n_ai, sizeof(n_ai_t));
|
|
memmove(&sgn_ff_indn.n_ai, &strm->pdu.n_ai, sizeof(n_ai_t));
|
|
|
memmove(&sgn_ff_indn.n_pci, &strm->pdu.n_pci, sizeof(n_pci_t));
|
|
memmove(&sgn_ff_indn.n_pci, &strm->pdu.n_pci, sizeof(n_pci_t));
|
|
|
strm->sts = (uint8_t)((uint32_t)strm->sts | (uint32_t)N_S_RX_BUSY);
|
|
strm->sts = (uint8_t)((uint32_t)strm->sts | (uint32_t)N_S_RX_BUSY);
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("send event to upper,N_FF_INDN,strm->sts:0x%x", strm->sts);
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("send event to upper,N_FF_INDN,strm->sts:0x%x", strm->sts);
|
|
|
cb(&sgn_ff_indn);
|
|
cb(&sgn_ff_indn);
|
|
|
break;
|
|
break;
|
|
|
case N_CONF:
|
|
case N_CONF:
|
|
@@ -612,9 +574,7 @@ inline static void signaling(signal_tp tp, n_iostream_t* strm, void(*cb)(void*),
|
|
|
sgn_conf.frame_type = N_PCI_T_FC;
|
|
sgn_conf.frame_type = N_PCI_T_FC;
|
|
|
memmove(&sgn_conf.n_ai, &strm->pdu.n_ai, sizeof(n_ai_t));
|
|
memmove(&sgn_conf.n_ai, &strm->pdu.n_ai, sizeof(n_ai_t));
|
|
|
memmove(&sgn_conf.n_pci, &strm->pdu.n_pci, sizeof(n_pci_t));
|
|
memmove(&sgn_conf.n_pci, &strm->pdu.n_pci, sizeof(n_pci_t));
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("send event to upper,N_CONF,strm->sts:0x%x", strm->sts);
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("send event to upper,N_CONF,strm->sts:0x%x", strm->sts);
|
|
|
cb(&sgn_conf);
|
|
cb(&sgn_conf);
|
|
|
break;
|
|
break;
|
|
|
default:
|
|
default:
|
|
@@ -634,8 +594,8 @@ inline static n_rslt process_timeouts(iso15765_t* ih)
|
|
|
{
|
|
{
|
|
|
return N_OK;
|
|
return N_OK;
|
|
|
}
|
|
}
|
|
|
- DLOG_I("sts:%d,last_upd.n_bs:%d,config_n_bs:%d,get_ms:%d", ih->out.sts, ih->out.last_upd.n_bs, ih->config.n_bs, ih->clbs.get_ms());
|
|
|
|
|
- DLOG_I("n_bs timeout");
|
|
|
|
|
|
|
+ LOG_I("sts:%d,last_upd.n_bs:%d,config_n_bs:%d,get_ms:%d", ih->out.sts, ih->out.last_upd.n_bs, ih->config.n_bs, ih->clbs.get_ms());
|
|
|
|
|
+ LOG_I("n_bs timeout");
|
|
|
/* if timeout occures then reset the counters and report to the upper layer */
|
|
/* if timeout occures then reset the counters and report to the upper layer */
|
|
|
ih->out.cf_cnt = 0x0;
|
|
ih->out.cf_cnt = 0x0;
|
|
|
signaling(N_INDN, &ih->out, (void*)ih->clbs.indn, ih->out.msg_sz, N_TIMEOUT_Bs);
|
|
signaling(N_INDN, &ih->out, (void*)ih->clbs.indn, ih->out.msg_sz, N_TIMEOUT_Bs);
|
|
@@ -651,6 +611,7 @@ static n_rslt send_N_PCI_T_FC(iso15765_t* ih)
|
|
|
uint32_t id;
|
|
uint32_t id;
|
|
|
|
|
|
|
|
ih->out.sts |= N_S_TX_BUSY;
|
|
ih->out.sts |= N_S_TX_BUSY;
|
|
|
|
|
+ LOG_I("ih->out.sts:%d", ih->out.sts);
|
|
|
ih->fl_pdu.n_pci.pt = N_PCI_T_FC;
|
|
ih->fl_pdu.n_pci.pt = N_PCI_T_FC;
|
|
|
ih->fl_pdu.n_pci.bs = ih->config.bs;
|
|
ih->fl_pdu.n_pci.bs = ih->config.bs;
|
|
|
ih->fl_pdu.n_pci.st = ih->config.stmin;
|
|
ih->fl_pdu.n_pci.st = ih->config.stmin;
|
|
@@ -660,22 +621,17 @@ static n_rslt send_N_PCI_T_FC(iso15765_t* ih)
|
|
|
ih->fl_pdu.n_ai.n_pr = ih->in.pdu.n_ai.n_pr;
|
|
ih->fl_pdu.n_ai.n_pr = ih->in.pdu.n_ai.n_pr;
|
|
|
ih->fl_pdu.n_ai.n_tt = ih->in.pdu.n_ai.n_tt;
|
|
ih->fl_pdu.n_ai.n_tt = ih->in.pdu.n_ai.n_tt;
|
|
|
ih->in.cfg_bs = ih->config.bs;
|
|
ih->in.cfg_bs = ih->config.bs;
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("n_pdu_pack");
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("n_pdu_pack");
|
|
|
if (n_pdu_pack(ih->addr_md, &ih->fl_pdu, &id, ih->out.msg) != N_OK)
|
|
if (n_pdu_pack(ih->addr_md, &ih->fl_pdu, &id, ih->out.msg) != N_OK)
|
|
|
{
|
|
{
|
|
|
ih->out.sts = (stream_sts)(ih->out.sts & (~N_S_TX_BUSY));
|
|
ih->out.sts = (stream_sts)(ih->out.sts & (~N_S_TX_BUSY));
|
|
|
|
|
+ LOG_I("ih->out.sts:%d", ih->out.sts);
|
|
|
return N_ERROR;
|
|
return N_ERROR;
|
|
|
}
|
|
}
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("send_N_PCI_T_FC,send_frame");
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("send_N_PCI_T_FC,send_frame");
|
|
|
ih->clbs.send_frame(ih->fr_id_type, id, ih->in.fr_fmt, n_get_dt_offset(ih->addr_md, N_PCI_T_FC, ih->fl_pdu.sz), ih->fl_pdu.dt);
|
|
ih->clbs.send_frame(ih->fr_id_type, id, ih->in.fr_fmt, n_get_dt_offset(ih->addr_md, N_PCI_T_FC, ih->fl_pdu.sz), ih->fl_pdu.dt);
|
|
|
ih->out.sts = (ih->out.sts & (~N_S_TX_BUSY));
|
|
ih->out.sts = (ih->out.sts & (~N_S_TX_BUSY));
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("ih->out.sts:%d", ih->out.sts);
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("ih->out.sts:%d", ih->out.sts);
|
|
|
return N_OK;
|
|
return N_OK;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -687,6 +643,7 @@ inline static void set_stream_data(n_iostream_t* ist, uint8_t cf, uint8_t wf, st
|
|
|
ist->cf_cnt = cf;
|
|
ist->cf_cnt = cf;
|
|
|
ist->wf_cnt = wf;
|
|
ist->wf_cnt = wf;
|
|
|
ist->sts = sts;
|
|
ist->sts = sts;
|
|
|
|
|
+ LOG_I("ist->sts %d", ist->sts);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -720,9 +677,7 @@ static n_rslt process_in_ff(iso15765_t* ih, canbus_frame_t* frame)
|
|
|
* process the FF N_PDU as the start of a new reception.*/
|
|
* process the FF N_PDU as the start of a new reception.*/
|
|
|
if ((ih->in.sts & N_S_RX_BUSY) != 0)
|
|
if ((ih->in.sts & N_S_RX_BUSY) != 0)
|
|
|
{
|
|
{
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_E("N_UNE_PDU");
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("N_UNE_PDU");
|
|
|
ih->clbs.on_error(N_UNE_PDU);
|
|
ih->clbs.on_error(N_UNE_PDU);
|
|
|
signaling(N_INDN, &ih->in, (void*)ih->clbs.indn, ih->in.msg_sz, N_UNE_PDU);
|
|
signaling(N_INDN, &ih->in, (void*)ih->clbs.indn, ih->in.msg_sz, N_UNE_PDU);
|
|
|
}
|
|
}
|
|
@@ -731,15 +686,11 @@ static n_rslt process_in_ff(iso15765_t* ih, canbus_frame_t* frame)
|
|
|
memmove(ih->in.msg, ih->in.pdu.dt, ih->in.pdu.sz);
|
|
memmove(ih->in.msg, ih->in.pdu.dt, ih->in.pdu.sz);
|
|
|
ih->in.msg_sz = ih->in.pdu.n_pci.dl; //????????
|
|
ih->in.msg_sz = ih->in.pdu.n_pci.dl; //????????
|
|
|
ih->in.msg_pos = ih->in.pdu.sz;
|
|
ih->in.msg_pos = ih->in.pdu.sz;
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("msg_sz:%d,msg_pos:%d", ih->in.msg_sz, ih->in.msg_pos);
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("msg_sz:%d,msg_pos:%d", ih->in.msg_sz, ih->in.msg_pos);
|
|
|
ih->in.cf_cnt = 0;
|
|
ih->in.cf_cnt = 0;
|
|
|
ih->in.wf_cnt = 0;
|
|
ih->in.wf_cnt = 0;
|
|
|
signaling(N_FF_INDN, &ih->in, (void*)ih->clbs.ff_indn, ih->in.msg_sz, N_OK);
|
|
signaling(N_FF_INDN, &ih->in, (void*)ih->clbs.ff_indn, ih->in.msg_sz, N_OK);
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("send_N_PCI_T_FC");
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("send_N_PCI_T_FC");
|
|
|
send_N_PCI_T_FC(ih);
|
|
send_N_PCI_T_FC(ih);
|
|
|
return N_OK;
|
|
return N_OK;
|
|
|
}
|
|
}
|
|
@@ -753,20 +704,15 @@ static n_rslt process_in_sf(iso15765_t* ih, canbus_frame_t* frame)
|
|
|
/* If reception is in progress: Terminate the current reception, report an
|
|
/* If reception is in progress: Terminate the current reception, report an
|
|
|
* N_USData.indication, with <N_Result> set to N_UNEXP_PDU, to the upper layer, and
|
|
* N_USData.indication, with <N_Result> set to N_UNEXP_PDU, to the upper layer, and
|
|
|
* process the SF N_PDU as the start of a new reception.*/
|
|
* process the SF N_PDU as the start of a new reception.*/
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("ih->in.sts:0x%x", ih->in.sts); //?????????IDLE???????????
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("ih->in.sts:0x%x", ih->in.sts); //?????????IDLE???????????
|
|
|
// if ((ih->in.sts & N_S_RX_BUSY) != 0)
|
|
// if ((ih->in.sts & N_S_RX_BUSY) != 0)
|
|
|
// {
|
|
// {
|
|
|
-// #if DEBUG_LOG_EN
|
|
|
|
|
-// LOG_E("N_UNE_PDU");
|
|
|
|
|
-// #endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+// LOG_I("N_UNE_PDU");
|
|
|
// ih->clbs.on_error(N_UNE_PDU);
|
|
// ih->clbs.on_error(N_UNE_PDU);
|
|
|
// signaling(N_INDN, &ih->in, (void*)ih->clbs.indn, ih->in.msg_sz, N_UNE_PDU);
|
|
// signaling(N_INDN, &ih->in, (void*)ih->clbs.indn, ih->in.msg_sz, N_UNE_PDU);
|
|
|
// }
|
|
// }
|
|
|
memmove(&ih->in.sf_msg[0], ih->in.pdu.sf_dt, ih->in.pdu.n_pci.dl);//????payload.
|
|
memmove(&ih->in.sf_msg[0], ih->in.pdu.sf_dt, ih->in.pdu.n_pci.dl);//????payload.
|
|
|
// ih->in.sts = N_S_IDLE;
|
|
// ih->in.sts = N_S_IDLE;
|
|
|
- //???????????.
|
|
|
|
|
signaling(N_SF_INDN, &ih->in, (void*)ih->clbs.indn, ih->in.pdu.n_pci.dl, N_OK);
|
|
signaling(N_SF_INDN, &ih->in, (void*)ih->clbs.indn, ih->in.pdu.n_pci.dl, N_OK);
|
|
|
return N_OK;
|
|
return N_OK;
|
|
|
}
|
|
}
|
|
@@ -790,10 +736,8 @@ static n_rslt process_in_cf(iso15765_t* ih, canbus_frame_t* frame)
|
|
|
|
|
|
|
|
/* Increase the CF counter and check if the reception sequence is ok */
|
|
/* Increase the CF counter and check if the reception sequence is ok */
|
|
|
ih->in.cf_cnt = ih->in.cf_cnt + 1 > 0x0F ? 0 : ih->in.cf_cnt + 1;
|
|
ih->in.cf_cnt = ih->in.cf_cnt + 1 > 0x0F ? 0 : ih->in.cf_cnt + 1;
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("ih->in.cf_cnt:%d,val:%d", ih->in.cf_cnt, ih->in.cf_cnt & 0x0f);
|
|
|
|
|
- LOG_D("ih->in.pdu.n_pci.sn:%d", ih->in.pdu.n_pci.sn);
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("ih->in.cf_cnt:%d,val:%d", ih->in.cf_cnt, ih->in.cf_cnt & 0x0f);
|
|
|
|
|
+ LOG_I("ih->in.pdu.n_pci.sn:%d", ih->in.pdu.n_pci.sn);
|
|
|
if ((ih->in.cf_cnt & 0x0f) != ih->in.pdu.n_pci.sn)
|
|
if ((ih->in.cf_cnt & 0x0f) != ih->in.pdu.n_pci.sn)
|
|
|
{
|
|
{
|
|
|
rslt = N_INV_SEQ_NUM;
|
|
rslt = N_INV_SEQ_NUM;
|
|
@@ -815,15 +759,13 @@ static n_rslt process_in_cf(iso15765_t* ih, canbus_frame_t* frame)
|
|
|
return N_OK;
|
|
return N_OK;
|
|
|
}
|
|
}
|
|
|
/* if we reach the max CF counter, then we send a FC frame */
|
|
/* if we reach the max CF counter, then we send a FC frame */
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("ih->config.bs:0x%x,ih->in.cf_cnt:0x%x",ih->config.bs,ih->in.cf_cnt);
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("ih->config.bs:0x%x,ih->in.cf_cnt:0x%x",ih->config.bs,ih->in.cf_cnt);
|
|
|
if(ih->config.bs != 0)
|
|
if(ih->config.bs != 0)
|
|
|
{
|
|
{
|
|
|
if (ih->in.cf_cnt == ih->config.bs)
|
|
if (ih->in.cf_cnt == ih->config.bs)
|
|
|
{
|
|
{
|
|
|
// ih->in.cf_cnt = 0;
|
|
// ih->in.cf_cnt = 0;
|
|
|
- // LOG_D("send_N_PCI_T_FC");
|
|
|
|
|
|
|
+ // LOG_I("send_N_PCI_T_FC");
|
|
|
// send_N_PCI_T_FC(ih);
|
|
// send_N_PCI_T_FC(ih);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -834,6 +776,7 @@ static n_rslt process_in_cf(iso15765_t* ih, canbus_frame_t* frame)
|
|
|
in_cf_error:
|
|
in_cf_error:
|
|
|
ih->clbs.on_error(rslt);
|
|
ih->clbs.on_error(rslt);
|
|
|
ih->in.sts = N_S_IDLE;
|
|
ih->in.sts = N_S_IDLE;
|
|
|
|
|
+ LOG_I("ih->in.sts:0x%x", ih->in.sts);
|
|
|
return rslt;
|
|
return rslt;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -844,17 +787,14 @@ in_cf_error:
|
|
|
static n_rslt process_in_fc(iso15765_t* ih, canbus_frame_t* frame)
|
|
static n_rslt process_in_fc(iso15765_t* ih, canbus_frame_t* frame)
|
|
|
{
|
|
{
|
|
|
n_rslt rslt = N_UNE_PDU;
|
|
n_rslt rslt = N_UNE_PDU;
|
|
|
-
|
|
|
|
|
- DLOG_I("ih->out.sts:%d", ih->out.sts);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ LOG_I("ih->out.sts:%d", ih->out.sts);
|
|
|
|
|
+ LOG_I("ih->in.pdu.n_pci.fs:%d", ih->in.pdu.n_pci.fs);
|
|
|
/* According to (ref: iso15765-2 p.26) if we are not expecting FC frame
|
|
/* According to (ref: iso15765-2 p.26) if we are not expecting FC frame
|
|
|
* we should ignore it */
|
|
* we should ignore it */
|
|
|
- if (ih->out.sts != N_S_TX_WAIT_FC)
|
|
|
|
|
- {
|
|
|
|
|
- return rslt;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- DLOG_I("ih->in.pdu.n_pci.fs:%d", ih->in.pdu.n_pci.fs);
|
|
|
|
|
|
|
+ // if (ih->out.sts != N_S_TX_WAIT_FC)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // return rslt;
|
|
|
|
|
+ // }
|
|
|
|
|
|
|
|
switch (ih->in.pdu.n_pci.fs)
|
|
switch (ih->in.pdu.n_pci.fs)
|
|
|
{
|
|
{
|
|
@@ -892,6 +832,7 @@ static n_rslt process_in_fc(iso15765_t* ih, canbus_frame_t* frame)
|
|
|
set_stream_data(&ih->out, 0, 0, N_S_IDLE);
|
|
set_stream_data(&ih->out, 0, 0, N_S_IDLE);
|
|
|
ih->clbs.on_error(rslt);
|
|
ih->clbs.on_error(rslt);
|
|
|
ih->in.sts = N_S_IDLE;
|
|
ih->in.sts = N_S_IDLE;
|
|
|
|
|
+ LOG_I("ih->in.sts:0x%x", ih->in.sts);
|
|
|
return rslt;
|
|
return rslt;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -904,36 +845,24 @@ inline static n_rslt iso15765_process_in(iso15765_t* ih, canbus_frame_t* frame)
|
|
|
{
|
|
{
|
|
|
/* Converting the canbus frame to PDU format and process it by its PCI Type */
|
|
/* Converting the canbus frame to PDU format and process it by its PCI Type */
|
|
|
ih->in.fr_fmt = (cbus_fr_format)frame->fr_format;
|
|
ih->in.fr_fmt = (cbus_fr_format)frame->fr_format;
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("process_frame:0x%x", frame->fr_format);
|
|
|
|
|
- LOG_D("can_frame_id:0x%x", frame->id);
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("process_frame:0x%x", frame->fr_format);
|
|
|
|
|
+ LOG_I("can_frame_id:0x%x", frame->id);
|
|
|
if (n_pdu_unpack(ih->addr_md, &ih->in.pdu, frame->id, (uint8_t)frame->dlc, frame->dt) == N_OK)
|
|
if (n_pdu_unpack(ih->addr_md, &ih->in.pdu, frame->id, (uint8_t)frame->dlc, frame->dt) == N_OK)
|
|
|
{
|
|
{
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("ih->in.pdu.n_pci.pt:0x%x", ih->in.pdu.n_pci.pt);
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("ih->in.pdu.n_pci.pt:0x%x", ih->in.pdu.n_pci.pt);
|
|
|
switch (ih->in.pdu.n_pci.pt)
|
|
switch (ih->in.pdu.n_pci.pt)
|
|
|
{
|
|
{
|
|
|
case N_PCI_T_SF:
|
|
case N_PCI_T_SF:
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("now process N_PCI_T_SF");
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("now process N_PCI_T_SF");
|
|
|
return process_in_sf(ih, frame);
|
|
return process_in_sf(ih, frame);
|
|
|
case N_PCI_T_FF:
|
|
case N_PCI_T_FF:
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("now process N_PCI_T_FF");
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("now process N_PCI_T_FF");
|
|
|
return process_in_ff(ih, frame);
|
|
return process_in_ff(ih, frame);
|
|
|
case N_PCI_T_CF:
|
|
case N_PCI_T_CF:
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("now process N_PCI_T_CF");
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("now process N_PCI_T_CF");
|
|
|
return process_in_cf(ih, frame);
|
|
return process_in_cf(ih, frame);
|
|
|
case N_PCI_T_FC:
|
|
case N_PCI_T_FC:
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("now process N_PCI_T_FC");
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("now process N_PCI_T_FC");
|
|
|
return process_in_fc(ih, frame);
|
|
return process_in_fc(ih, frame);
|
|
|
default:
|
|
default:
|
|
|
break;
|
|
break;
|
|
@@ -956,7 +885,7 @@ static n_rslt iso15765_process_out(iso15765_t* ih)
|
|
|
{
|
|
{
|
|
|
return N_IDLE;
|
|
return N_IDLE;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ LOG_I("ih->out.sts:%d", ih->out.sts);
|
|
|
uint32_t id;
|
|
uint32_t id;
|
|
|
n_rslt rslt = N_ERROR;
|
|
n_rslt rslt = N_ERROR;
|
|
|
addr_md addr_mode = ih->addr_md;
|
|
addr_md addr_mode = ih->addr_md;
|
|
@@ -969,18 +898,15 @@ static n_rslt iso15765_process_out(iso15765_t* ih)
|
|
|
/* Find the PCI type of the pending outbound stream */
|
|
/* Find the PCI type of the pending outbound stream */
|
|
|
ih->out.pdu.n_pci.pt = n_out_frame_type(ih);
|
|
ih->out.pdu.n_pci.pt = n_out_frame_type(ih);
|
|
|
tmp_type = n_out_frame_type(ih);
|
|
tmp_type = n_out_frame_type(ih);
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("ih->out.pdu.n_pci.pt:0x%x", ih->out.pdu.n_pci.pt);
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("ih->out.pdu.n_pci.pt:0x%x", ih->out.pdu.n_pci.pt);
|
|
|
|
|
+ LOG_I("tmp_type:%d", tmp_type);
|
|
|
switch (tmp_type)
|
|
switch (tmp_type)
|
|
|
{
|
|
{
|
|
|
case N_PCI_T_SF:
|
|
case N_PCI_T_SF:
|
|
|
/* Copy all the data of the SF to the outbound stream, pack and send the canbus frame */
|
|
/* Copy all the data of the SF to the outbound stream, pack and send the canbus frame */
|
|
|
ih->out.pdu.n_pci.dl = ih->out.msg_sz;
|
|
ih->out.pdu.n_pci.dl = ih->out.msg_sz;
|
|
|
ih->out.pdu.sz = ih->out.msg_sz;
|
|
ih->out.pdu.sz = ih->out.msg_sz;
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("n_pdu_pack");
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("n_pdu_pack");
|
|
|
if (n_pdu_pack(ih->addr_md, &ih->out.pdu, &id, ih->out.msg) != N_OK)
|
|
if (n_pdu_pack(ih->addr_md, &ih->out.pdu, &id, ih->out.msg) != N_OK)
|
|
|
{
|
|
{
|
|
|
goto iso15765_process_out_cfm;
|
|
goto iso15765_process_out_cfm;
|
|
@@ -993,16 +919,12 @@ static n_rslt iso15765_process_out(iso15765_t* ih)
|
|
|
case N_PCI_T_FF:
|
|
case N_PCI_T_FF:
|
|
|
/* Copy all the data of the FF to the outbound stream for transmission and prepare the service
|
|
/* Copy all the data of the FF to the outbound stream for transmission and prepare the service
|
|
|
* for a multi-frame reception */
|
|
* for a multi-frame reception */
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("addr_mode:0x%x", addr_mode);
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("addr_mode:0x%x", addr_mode);
|
|
|
ih->out.pdu.n_pci.dl = ih->out.msg_sz;
|
|
ih->out.pdu.n_pci.dl = ih->out.msg_sz;
|
|
|
ih->out.wf_cnt = 0;
|
|
ih->out.wf_cnt = 0;
|
|
|
ih->out.pdu.sz = ih->out.fr_fmt == CBUS_FR_FRM_STD ? ((addr_mode & 0x01) == 0 ? 6 : 5) : ((addr_mode & 0x01) == 0 ? 62 : 61);
|
|
ih->out.pdu.sz = ih->out.fr_fmt == CBUS_FR_FRM_STD ? ((addr_mode & 0x01) == 0 ? 6 : 5) : ((addr_mode & 0x01) == 0 ? 62 : 61);
|
|
|
ih->out.msg_pos = ih->out.pdu.sz;
|
|
ih->out.msg_pos = ih->out.pdu.sz;
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("n_pdu_pack");
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("n_pdu_pack");
|
|
|
if (n_pdu_pack(ih->addr_md, &ih->out.pdu, &id, ih->out.msg) != N_OK)
|
|
if (n_pdu_pack(ih->addr_md, &ih->out.pdu, &id, ih->out.msg) != N_OK)
|
|
|
{
|
|
{
|
|
|
goto iso15765_process_out_cfm;
|
|
goto iso15765_process_out_cfm;
|
|
@@ -1012,6 +934,7 @@ static n_rslt iso15765_process_out(iso15765_t* ih)
|
|
|
/* after this frame we expect a Flow Control then assign the correct flag before the
|
|
/* after this frame we expect a Flow Control then assign the correct flag before the
|
|
|
* transmission to avoid any issues and start the timer */
|
|
* transmission to avoid any issues and start the timer */
|
|
|
ih->out.sts = N_S_TX_WAIT_FC;
|
|
ih->out.sts = N_S_TX_WAIT_FC;
|
|
|
|
|
+ LOG_I("ih->out.sts:%d", ih->out.sts);
|
|
|
rslt = ih->clbs.send_frame(ih->fr_id_type, id, ih->out.fr_fmt, ih->out.fr_fmt == CBUS_FR_FRM_STD ? 8 : 64, ih->out.pdu.dt) == 0 ? N_OK : N_ERROR;
|
|
rslt = ih->clbs.send_frame(ih->fr_id_type, id, ih->out.fr_fmt, ih->out.fr_fmt == CBUS_FR_FRM_STD ? 8 : 64, ih->out.pdu.dt) == 0 ? N_OK : N_ERROR;
|
|
|
ih->out.last_upd.n_bs = ih->clbs.get_ms();
|
|
ih->out.last_upd.n_bs = ih->clbs.get_ms();
|
|
|
return (rslt == 0) ? N_OK : N_ERROR;
|
|
return (rslt == 0) ? N_OK : N_ERROR;
|
|
@@ -1027,11 +950,16 @@ static n_rslt iso15765_process_out(iso15765_t* ih)
|
|
|
* and then pack the PDU to a CANBus frame */
|
|
* and then pack the PDU to a CANBus frame */
|
|
|
ih->out.pdu.n_pci.sn = ih->out.cf_cnt & 0x0F;
|
|
ih->out.pdu.n_pci.sn = ih->out.cf_cnt & 0x0F;
|
|
|
ih->out.cf_cnt = ih->out.cf_cnt == 0xFF ? 0 : ih->out.cf_cnt + 1;
|
|
ih->out.cf_cnt = ih->out.cf_cnt == 0xFF ? 0 : ih->out.cf_cnt + 1;
|
|
|
|
|
+
|
|
|
|
|
+ LOG_I("ih->out.fr_fmt:%d", ih->out.fr_fmt);
|
|
|
if (ih->out.fr_fmt == CBUS_FR_FRM_STD)
|
|
if (ih->out.fr_fmt == CBUS_FR_FRM_STD)
|
|
|
{
|
|
{
|
|
|
uint8_t max_payload = (addr_mode & 0x01) == 0 ? 7 : 6;
|
|
uint8_t max_payload = (addr_mode & 0x01) == 0 ? 7 : 6;
|
|
|
|
|
+ LOG_I("max_payload:%d", max_payload);
|
|
|
ih->out.pdu.sz = ih->out.msg_sz - ih->out.msg_pos;
|
|
ih->out.pdu.sz = ih->out.msg_sz - ih->out.msg_pos;
|
|
|
|
|
+ LOG_I("ih->out.pdu.sz:%d", ih->out.pdu.sz);
|
|
|
ih->out.pdu.sz = ih->out.pdu.sz >= max_payload ? max_payload : ih->out.pdu.sz;
|
|
ih->out.pdu.sz = ih->out.pdu.sz >= max_payload ? max_payload : ih->out.pdu.sz;
|
|
|
|
|
+ LOG_I("ih->out.pdu.sz:%d", ih->out.pdu.sz);
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
@@ -1039,9 +967,9 @@ static n_rslt iso15765_process_out(iso15765_t* ih)
|
|
|
ih->out.pdu.sz = ih->out.msg_sz - ih->out.msg_pos;
|
|
ih->out.pdu.sz = ih->out.msg_sz - ih->out.msg_pos;
|
|
|
ih->out.pdu.sz = ih->out.pdu.sz >= max_payload ? max_payload : ih->out.pdu.sz;
|
|
ih->out.pdu.sz = ih->out.pdu.sz >= max_payload ? max_payload : ih->out.pdu.sz;
|
|
|
}
|
|
}
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("n_pdu_pack");
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+
|
|
|
|
|
+ LOG_I("sn:%d,cnt:%d,sz:%d",ih->out.pdu.n_pci.sn, ih->out.cf_cnt, ih->out.pdu.sz);
|
|
|
|
|
+ LOG_I("n_pdu_pack");
|
|
|
if (n_pdu_pack(ih->addr_md, &ih->out.pdu, &id, &ih->out.msg[ih->out.msg_pos]) != N_OK)
|
|
if (n_pdu_pack(ih->addr_md, &ih->out.pdu, &id, &ih->out.msg[ih->out.msg_pos]) != N_OK)
|
|
|
{
|
|
{
|
|
|
goto iso15765_process_out_cfm;
|
|
goto iso15765_process_out_cfm;
|
|
@@ -1055,6 +983,7 @@ static n_rslt iso15765_process_out(iso15765_t* ih)
|
|
|
if (ih->out.pdu.n_pci.sn == ih->config.bs)
|
|
if (ih->out.pdu.n_pci.sn == ih->config.bs)
|
|
|
{
|
|
{
|
|
|
ih->out.sts = N_S_TX_WAIT_FC;
|
|
ih->out.sts = N_S_TX_WAIT_FC;
|
|
|
|
|
+ LOG_I("ih->out.sts:%d", ih->out.sts);
|
|
|
ih->out.last_upd.n_bs = ih->clbs.get_ms();
|
|
ih->out.last_upd.n_bs = ih->clbs.get_ms();
|
|
|
}
|
|
}
|
|
|
/* send the canbus frame! */
|
|
/* send the canbus frame! */
|
|
@@ -1075,9 +1004,9 @@ static n_rslt iso15765_process_out(iso15765_t* ih)
|
|
|
|
|
|
|
|
iso15765_process_out_cfm:
|
|
iso15765_process_out_cfm:
|
|
|
ih->out.sts = N_S_IDLE;
|
|
ih->out.sts = N_S_IDLE;
|
|
|
|
|
+ LOG_I("ih->out.sts:%d", ih->out.sts);
|
|
|
ih->out.cf_cnt = 0;
|
|
ih->out.cf_cnt = 0;
|
|
|
ih->out.wf_cnt = 0;
|
|
ih->out.wf_cnt = 0;
|
|
|
- //??????????.
|
|
|
|
|
signaling(N_CONF, &ih->out, (void*)ih->clbs.cfm, 0, rslt);
|
|
signaling(N_CONF, &ih->out, (void*)ih->clbs.cfm, 0, rslt);
|
|
|
return rslt;
|
|
return rslt;
|
|
|
}
|
|
}
|
|
@@ -1166,6 +1095,7 @@ n_rslt iso15765_send(iso15765_t* instance, n_req_t* frame)
|
|
|
/* Make sure that there is no transmission in progress */
|
|
/* Make sure that there is no transmission in progress */
|
|
|
if (instance->out.sts != N_S_IDLE)
|
|
if (instance->out.sts != N_S_IDLE)
|
|
|
{
|
|
{
|
|
|
|
|
+ LOG_I("instance->out.sts:%d", instance->out.sts);
|
|
|
return N_TX_BUSY;
|
|
return N_TX_BUSY;
|
|
|
}
|
|
}
|
|
|
/* and the requested size is fitting in our outbound buffer */
|
|
/* and the requested size is fitting in our outbound buffer */
|
|
@@ -1180,6 +1110,7 @@ n_rslt iso15765_send(iso15765_t* instance, n_req_t* frame)
|
|
|
memmove(instance->out.msg, frame->msg, frame->msg_sz);
|
|
memmove(instance->out.msg, frame->msg, frame->msg_sz);
|
|
|
memmove(&instance->out.pdu.n_ai, &frame->n_ai, sizeof(n_ai_t));
|
|
memmove(&instance->out.pdu.n_ai, &frame->n_ai, sizeof(n_ai_t));
|
|
|
instance->out.sts = N_S_TX_BUSY;
|
|
instance->out.sts = N_S_TX_BUSY;
|
|
|
|
|
+ LOG_I("instance->out.sts:%d", instance->out.sts);
|
|
|
|
|
|
|
|
return N_OK;
|
|
return N_OK;
|
|
|
}
|
|
}
|