]> rtime.felk.cvut.cz Git - arc.git/commitdiff
more work on j1939tp
authornier <devnull@localhost>
Mon, 12 Sep 2011 09:02:46 +0000 (11:02 +0200)
committernier <devnull@localhost>
Mon, 12 Sep 2011 09:02:46 +0000 (11:02 +0200)
communication/J1939Tp/J1939Tp.c
communication/J1939Tp/J1939Tp_Internal.h

index 51a569519cec66b8762e04d288223622173c13eb..fa1ef23f42304983cb651f3288554ed7f95226c4 100644 (file)
@@ -4,8 +4,13 @@
 #include "PdurR_J1939Tp.h"\r
 \r
 /** @req J1939TP0019 */\r
-static J1939Tp_GlobalStateType globalState = J1939TP_OFF;\r
+static J1939Tp_Internal_GlobalStateInfoType globalState = {\r
+               .State = J1939TP_OFF,\r
+};\r
 static const J1939Tp_ConfigType* J1939Tp_ConfigPtr;\r
+static J1939Tp_Internal_TxPgStateType txPgState[J1939TP_TX_PG_COUNT];\r
+\r
+\r
 \r
 /** @req J1939TP0087 */\r
 void J1939Tp_Init(const J1939Tp_ConfigType* ConfigPtr) {\r
@@ -17,12 +22,24 @@ void J1939Tp_Init(const J1939Tp_ConfigType* ConfigPtr) {
        }\r
        #endif\r
        J1939Tp_ConfigPtr = ConfigPtr;\r
-       globalState = J1939TP_ON; /** @req J1939TP0022 */\r
+       globalState.State = J1939TP_ON; /** @req J1939TP0022 */\r
 }\r
 void J1939Tp_RxIndication(PduIdType RxPduId, PduInfoType* PduInfoPtr) {\r
 \r
 }\r
 \r
+void J1939_MainFunction(void) {\r
+       for (int i = 0; i < J1939TP_TX_PG_COUNT; i++) {\r
+               switch (J1939Tp_Internal_GetTxPg(i)->State) {\r
+                       case J1939TP_WAITING_FOR_CM:\r
+\r
+                               break;\r
+                       default:\r
+                               break;\r
+               }\r
+       }\r
+}\r
+\r
 /** @req J1939TP0180 */\r
 Std_ReturnType J1939Tp_ChangeParameterRequest(PduIdType SduId, TPParameterType Parameter, uint16 value) {\r
        return E_NOT_OK; /** @req J1939TP0181 */\r
@@ -51,15 +68,28 @@ Std_ReturnType J1939Tp_Transmit(PduIdType TxSduId, const PduInfoType* TxInfoPtr)
                                break;\r
                        case J1939TP_PROTOCOL_CMDT:\r
                                J1939Tp_Internal_SendRts(TxSduId,TxInfoPtr);\r
+                               J1939Tp_Internal_SetStateTxPg(TxSduId,J1939TP_RTS_SENT);\r
                                break;\r
                }\r
        }\r
        return E_OK;\r
 }\r
 \r
-\r
-static inline const J1939Tp_PgType* J1939Tp_Internal_ConfGetTxPg(uint32 txPduId) {\r
-       return &(J1939Tp_ConfigPtr->TxPgs[txPduId]);\r
+void J1939Tp_TxIndication(PduIdType TxPduId) {\r
+       J1939Tp_Internal_TxPgStateInfoType* pgState = J1939Tp_Internal_GetTxPg(TxPduId);\r
+       switch (pgState) {\r
+               case J1939TP_RTS_SENT:\r
+                       J1939Tp_Internal_SetStateTxPg(TxSduId,J1939TP_WAIT_FOR_CM);\r
+                       break;\r
+               default:\r
+                       break;\r
+       }\r
+}\r
+static inline void J1939Tp_Internal_SetStateTxPg(uint32 txPduId,J1939Tp_Internal_TxPgStateType state) {\r
+       txPgState[txPduId].State = state;\r
+}\r
+static inline J1939Tp_Internal_TxPgStateInfoType* J1939Tp_Internal_GetTxPg(uint32 txPduId) {\r
+       return &(txPgState[txPduId]);\r
 }\r
 static inline const J1939Tp_ChannelType* J1939Tp_Internal_ConfGetTxChannel(uint32 txPduId) {\r
        return J1939Tp_ConfigPtr->TxPgs[txPduId].Channel;\r
index 9397f795105c51eb9dbf6ce798fb3ad1e3e801bd..12ca02fe9a97606357144a2e8af87b08d0dc3571 100644 (file)
 #define RTS_PGN_VALUE_3                        0x00\r
 \r
 /** @req J1939TP0019 */\r
+\r
 typedef enum {\r
        J1939TP_ON,\r
        J1939TP_OFF\r
-} J1939Tp_GlobalStateType;\r
+} J1939Tp_Internal_GlobalStateType\r
+typedef struct {\r
+       J1939Tp_Internal_GlobalStateType State;\r
+       uint32 TimeElapsed;\r
+} J1939Tp_Internal_GlobalStateInfoType;\r
+\r
+typedef enum {\r
+       J1939TP_IDLE,\r
+       J1939TP_RTS_SENT,\r
+       J1939TP_WAITING_FOR_CM,\r
+} J1939Tp_Internal_TxPgStateType;\r
+\r
+enum states { IDLE, STATE_2, STATE_3, MAX_STATES } current_state;\r
+enum events { EVENT_1, EVENT_2, MAX_EVENTS } new_event;\r
 \r
 typedef struct {\r
-       boolean waitingForCts;\r
-} J1939Tp_Internal_TxPduStateType;\r
+       J1939Tp_Internal_TxPgStateType State;\r
+} J1939Tp_Internal_TxPgStateInfoType;\r
 \r
 static inline const J1939Tp_PgType* J1939Tp_Internal_ConfGetTxPg(uint32 txPduId);\r
 static void J1939Tp_Internal_SendRts(PduIdType TxSduId, const PduInfoType* TxInfoPtr);\r