|
@@ -38,7 +38,7 @@ SOFTWARE.
|
|
|
/******************************************************************************
|
|
/******************************************************************************
|
|
|
* Enumerations, structures & Variables
|
|
* Enumerations, structures & Variables
|
|
|
******************************************************************************/
|
|
******************************************************************************/
|
|
|
-#define DEBUG_LOG_EN 0
|
|
|
|
|
|
|
+#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;
|
|
@@ -220,9 +220,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)
|
|
@@ -277,37 +275,29 @@ 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
|
|
|
|
|
- printf("[%s:%d],dlc:%d,data:", __FUNCTION__, __LINE__, 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: //单帧
|
|
case N_PCI_T_SF: //单帧
|
|
|
n_pdu->n_pci.dl = dlc <= 8 ? (dt[0 + offs] & 0x0F) : (dt[1 + offs]); //计算返回应用的payload的长度.单帧dlc长度可以大于8么.?
|
|
n_pdu->n_pci.dl = dlc <= 8 ? (dt[0 + offs] & 0x0F) : (dt[1 + offs]); //计算返回应用的payload的长度.单帧dlc长度可以大于8么.?
|
|
|
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;
|
|
@@ -315,17 +305,13 @@ inline static n_rslt n_pci_unpack(addr_md mode, n_pdu_t* n_pdu, uint8_t dlc, ui
|
|
|
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_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);
|
|
|
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;
|
|
@@ -390,30 +376,24 @@ 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
|
|
#if DEBUG_LOG_EN
|
|
|
- LOG_D("copy N_PCI_T_FF data, len:%d", n_pdu->sz);
|
|
|
|
|
|
|
+ LOG_I("copy N_PCI_T_FF data, len:%d", n_pdu->sz);
|
|
|
#endif //DEBUG_LOG_EN
|
|
#endif //DEBUG_LOG_EN
|
|
|
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;
|
|
@@ -434,9 +414,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:
|
|
@@ -472,9 +450,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;
|
|
@@ -494,9 +470,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)
|
|
@@ -535,9 +509,7 @@ 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;
|
|
@@ -545,9 +517,7 @@ inline static n_rslt n_pdu_unpack(addr_md mode, n_pdu_t* n_pdu, uint32_t id, uin
|
|
|
|
|
|
|
|
n_pci_unpack(mode, n_pdu, dlc, dt); //获取帧类型和payload长度.
|
|
n_pci_unpack(mode, n_pdu, dlc, dt); //获取帧类型和payload长度.
|
|
|
n_pdu_unpack_dt(mode, n_pdu, dt); //拷贝数据.
|
|
n_pdu_unpack_dt(mode, n_pdu, dt); //拷贝数据.
|
|
|
-#if DEBUG_LOG_EN
|
|
|
|
|
- LOG_D("n_pdu_unpack_finish");
|
|
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
|
|
+ LOG_I("n_pdu_unpack_finish");
|
|
|
return N_OK;
|
|
return N_OK;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -558,9 +528,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)
|
|
@@ -574,9 +542,7 @@ 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
|
|
|
|
|
|
|
+ LOG_I("send event to upper,N_INDN,strm->sts:0x%x", strm->sts);
|
|
|
cb(&sgn_indn);//抛到上层.
|
|
cb(&sgn_indn);//抛到上层.
|
|
|
break;
|
|
break;
|
|
|
case N_SF_INDN:
|
|
case N_SF_INDN:
|
|
@@ -588,9 +554,7 @@ 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
|
|
|
|
|
|
|
+ LOG_I("send event to upper,N_SF_INDN,strm->sts:0x%x", strm->sts);
|
|
|
cb(&sf_indn);//抛到上层.
|
|
cb(&sf_indn);//抛到上层.
|
|
|
break;
|
|
break;
|
|
|
case N_FF_INDN:
|
|
case N_FF_INDN:
|
|
@@ -600,9 +564,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:
|
|
@@ -610,9 +572,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:
|
|
@@ -632,8 +592,8 @@ inline static n_rslt process_timeouts(iso15765_t* ih)
|
|
|
{
|
|
{
|
|
|
return N_OK;
|
|
return N_OK;
|
|
|
}
|
|
}
|
|
|
- LOG_D("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_D("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);
|
|
@@ -649,7 +609,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_D("ih->out.sts:%d", ih->out.sts);
|
|
|
|
|
|
|
+ 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;
|
|
@@ -659,23 +619,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_D("ih->out.sts:%d", ih->out.sts);
|
|
|
|
|
|
|
+ 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,7 +641,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_D("ist->sts %d", ist->sts);
|
|
|
|
|
|
|
+ LOG_I("ist->sts %d", ist->sts);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -721,9 +675,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");
|
|
LOG_E("N_UNE_PDU");
|
|
|
-#endif //DEBUG_LOG_EN
|
|
|
|
|
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);
|
|
|
}
|
|
}
|
|
@@ -732,15 +684,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;
|
|
|
}
|
|
}
|
|
@@ -754,14 +702,10 @@ 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");
|
|
// LOG_E("N_UNE_PDU");
|
|
|
-// #endif //DEBUG_LOG_EN
|
|
|
|
|
// 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);
|
|
|
// }
|
|
// }
|
|
@@ -791,10 +735,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;
|
|
@@ -816,15 +758,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);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -835,7 +775,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_D("ih->in.sts:0x%x", ih->in.sts);
|
|
|
|
|
|
|
+ LOG_I("ih->in.sts:0x%x", ih->in.sts);
|
|
|
|
|
|
|
|
return rslt;
|
|
return rslt;
|
|
|
}
|
|
}
|
|
@@ -848,7 +788,7 @@ 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;
|
|
|
|
|
|
|
|
- LOG_D("ih->out.sts:%d", ih->out.sts);
|
|
|
|
|
|
|
+ LOG_I("ih->out.sts:%d", ih->out.sts);
|
|
|
|
|
|
|
|
/* 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 */
|
|
@@ -857,7 +797,7 @@ static n_rslt process_in_fc(iso15765_t* ih, canbus_frame_t* frame)
|
|
|
// return rslt;
|
|
// return rslt;
|
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
- LOG_D("ih->in.pdu.n_pci.fs:%d", ih->in.pdu.n_pci.fs);
|
|
|
|
|
|
|
+ LOG_I("ih->in.pdu.n_pci.fs:%d", ih->in.pdu.n_pci.fs);
|
|
|
|
|
|
|
|
switch (ih->in.pdu.n_pci.fs)
|
|
switch (ih->in.pdu.n_pci.fs)
|
|
|
{
|
|
{
|
|
@@ -895,7 +835,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_D("ih->in.sts:0x%x", ih->in.sts);
|
|
|
|
|
|
|
+ LOG_I("ih->in.sts:0x%x", ih->in.sts);
|
|
|
return rslt;
|
|
return rslt;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -908,36 +848,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;
|
|
@@ -960,7 +888,7 @@ static n_rslt iso15765_process_out(iso15765_t* ih)
|
|
|
{
|
|
{
|
|
|
return N_IDLE;
|
|
return N_IDLE;
|
|
|
}
|
|
}
|
|
|
- LOG_D("ih->out.sts:%d", ih->out.sts);
|
|
|
|
|
|
|
+ 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;
|
|
@@ -974,18 +902,14 @@ 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);
|
|
|
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;
|
|
@@ -998,16 +922,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;
|
|
@@ -1017,7 +937,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_D("ih->out.sts:%d", ih->out.sts);
|
|
|
|
|
|
|
+ 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;
|
|
@@ -1033,7 +953,7 @@ 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_D("ih->out.fr_fmt:%d", ih->out.fr_fmt);
|
|
|
|
|
|
|
+ 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;
|
|
@@ -1046,10 +966,8 @@ 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("sn:%d,cnt:%d,sz:%d",ih->out.pdu.n_pci.sn, ih->out.cf_cnt, ih->out.pdu.sz);
|
|
|
|
|
- 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;
|
|
@@ -1063,7 +981,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_D("ih->out.sts:%d", ih->out.sts);
|
|
|
|
|
|
|
+ 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! */
|
|
@@ -1084,7 +1002,7 @@ 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_D("ih->out.sts:%d", ih->out.sts);
|
|
|
|
|
|
|
+ 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);
|
|
@@ -1175,7 +1093,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_D("instance->out.sts:%d", instance->out.sts);
|
|
|
|
|
|
|
+ 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 */
|
|
@@ -1190,7 +1108,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_D("instance->out.sts:%d", instance->out.sts);
|
|
|
|
|
|
|
+ LOG_I("instance->out.sts:%d", instance->out.sts);
|
|
|
|
|
|
|
|
return N_OK;
|
|
return N_OK;
|
|
|
}
|
|
}
|