-
-
Notifications
You must be signed in to change notification settings - Fork 62
Refactored CAN-TS-Bridge ecu sided changes #748
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
Open
DFlak
wants to merge
1
commit into
FOME-Tech:master
Choose a base branch
from
DFlak:can-ts-bridge-ecu
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,7 +55,7 @@ class IsoTpFrameHeader { | |
| // We need an abstraction layer for unit-testing | ||
| class ICanStreamer { | ||
| public: | ||
| virtual can_msg_t transmit(canmbx_t mailbox, const CanTxMessage* ctfp, can_sysinterval_t timeout) = 0; | ||
| virtual can_msg_t transmit(uint32_t eid, canmbx_t mailbox, const CanTxMessage* ctfp, can_sysinterval_t timeout) = 0; | ||
| virtual can_msg_t receive(canmbx_t mailbox, CANRxFrame* crfp, can_sysinterval_t timeout) = 0; | ||
| }; | ||
|
|
||
|
|
@@ -64,20 +64,24 @@ class CanStreamerState { | |
| fifo_buffer<uint8_t, CAN_FIFO_BUF_SIZE> rxFifoBuf; | ||
| fifo_buffer<uint8_t, CAN_FIFO_BUF_SIZE> txFifoBuf; | ||
|
|
||
| #if defined(TS_CAN_DEVICE_SHORT_PACKETS_IN_ONE_FRAME) | ||
| // used to restore the original packet with CRC | ||
| uint8_t tmpRxBuf[13]; | ||
| #endif | ||
|
|
||
|
|
||
| // used for multi-frame ISO-TP packets | ||
| int waitingForNumBytes = 0; | ||
| int waitingForFrameIndex = 0; | ||
|
|
||
| ICanStreamer* streamer; | ||
| uint32_t txId; | ||
| CanBusIndex busIndex; | ||
|
|
||
| public: | ||
| CanStreamerState(ICanStreamer* s) | ||
| : streamer(s) {} | ||
| : streamer(s), txId(0), busIndex(CanBusIndex::Bus0) {} | ||
|
|
||
| void init(uint32_t txIdValue, CanBusIndex busIndexValue) { | ||
| this->txId = txIdValue; | ||
| this->busIndex = busIndexValue; | ||
| } | ||
|
|
||
| int sendFrame(const IsoTpFrameHeader& header, const uint8_t* data, int num, can_sysinterval_t timeout); | ||
| int receiveFrame(CANRxFrame* rxmsg, uint8_t* buf, int num, can_sysinterval_t timeout); | ||
|
|
@@ -111,7 +115,15 @@ class CanRxMessage { | |
| class CanTsListener : public CanListener { | ||
| public: | ||
| CanTsListener() | ||
| : CanListener(CAN_ECU_SERIAL_RX_ID) {} | ||
| : CanListener(0) {} | ||
|
|
||
| void init(uint32_t idValue) { | ||
| m_id = idValue; | ||
| } | ||
|
|
||
| bool acceptFrame(CanBusIndex /*busIndex*/, const CANRxFrame& frame) const override { | ||
| return CAN_ID(frame) == m_id; | ||
| } | ||
|
|
||
| void decodeFrame(const CANRxFrame& frame, efitick_t nowNt) override; | ||
|
|
||
|
|
@@ -120,19 +132,20 @@ class CanTsListener : public CanListener { | |
| } | ||
|
|
||
| protected: | ||
| uint32_t m_id = 0; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this shadows the base class's m_id, intentional?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (add a protected setter to set the base class member, rather than shadowing) |
||
| fifo_buffer_sync<CanRxMessage, CAN_FIFO_FRAME_SIZE> rxFifo; | ||
| }; | ||
|
|
||
| #if HAL_USE_CAN | ||
| class CanStreamer : public ICanStreamer { | ||
| public: | ||
| void init(); | ||
| void init(uint32_t rxId); | ||
|
|
||
| virtual can_msg_t transmit(canmbx_t mailbox, const CanTxMessage* ctfp, can_sysinterval_t timeout) override; | ||
| virtual can_msg_t transmit(uint32_t eid, canmbx_t mailbox, const CanTxMessage* ctfp, can_sysinterval_t timeout) override; | ||
| virtual can_msg_t receive(canmbx_t mailbox, CANRxFrame* crfp, can_sysinterval_t timeout) override; | ||
| }; | ||
|
|
||
| void canStreamInit(void); | ||
| void canStreamInit(uint32_t rxId, uint32_t txId, CanBusIndex busIndex); | ||
|
|
||
| // we don't have canStreamSendTimeout() because we need to "bufferize" the stream and send it in fixed-length packets | ||
| msg_t canStreamAddToTxTimeout(size_t* np, const uint8_t* txbuf, sysinterval_t timeout); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why add this parameter? it's never used!