-
Notifications
You must be signed in to change notification settings - Fork 29
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
Test sketch block after 17 send messages #20
Comments
Hello,
I think it is better to write frame.data [i] = msg[i] ; instead of frame.data [i] = {msg[i]} ;
What do you mean by "failure" ? does the send process stop ?
Note a CAN controller should not be alone on a CAN bus. When a CAN controller sends a frame, it require an ACK from a receiver. No receiver, no ack. It is a failure for the CAN controller, so it sends again the frame. So an alone CAN controller sends repetitivly the same frame, without emptying the hardware send buffer. Next messages are stored in the driver send buffer. So the driver accepts messages until its send buffer is not full. So 17 messages are accepted (1 in the MCP2515 hadrware buffer, 16 in the driver send buffer).
Best regards,
Pierre Molinaro
… Le 2 oct. 2020 à 19:31, Mplex72 ***@***.***> a écrit :
What did I do wrong within this sketch on arduino UNO?
it will send only 17 meassages , then I have "failure" in the serial interface .
<
/*
*
*/
#include <ACAN2515.h>
static const byte MCP2515_CS = 10 ; // CS input of MCP2515 (adapt to your design)
static const byte MCP2515_INT = 3 ; // INT output of MCP2515 (adapt to your design)
ACAN2515 can (MCP2515_CS, SPI, MCP2515_INT) ;
static const uint32_t QUARTZ_FREQUENCY = 8UL * 1000UL * 1000UL ; // 8 MHz
void setup() {
Serial.begin (38400) ;
while (!Serial) {
delay (50) ;
digitalWrite (LED_BUILTIN, !digitalRead (LED_BUILTIN)) ;
}
SPI.begin () ;
ACAN2515Settings settings (QUARTZ_FREQUENCY, 500UL * 1000UL) ; // CAN bit rate 500 kb/s
const uint16_t errorCode = can.begin (settings, [] { can.isr () ; }) ;
if (errorCode == 0) {
Serial.print ("Bit Rate prescaler: ") ;
Serial.println (settings.mBitRatePrescaler) ;
Serial.print ("Propagation Segment: ") ;
Serial.println (settings.mPropagationSegment) ;
Serial.print ("Phase segment 1: ") ;
Serial.println (settings.mPhaseSegment1) ;
Serial.print ("Phase segment 2: ") ;
Serial.println (settings.mPhaseSegment2) ;
Serial.print ("SJW: ") ;
Serial.println (settings.mSJW) ;
Serial.print ("Triple Sampling: ") ;
Serial.println (settings.mTripleSampling ? "yes" : "no") ;
Serial.print ("Actual bit rate: ") ;
Serial.print (settings.actualBitRate ()) ;
Serial.println (" bit/s") ;
Serial.print ("Exact bit rate ? ") ;
Serial.println (settings.exactBitRate () ? "yes" : "no") ;
Serial.print ("Sample point: ") ;
Serial.print (settings.samplePointFromBitStart ()) ;
Serial.println ("%") ;
}else{
Serial.print ("Configuration error 0x") ;
Serial.println (errorCode, HEX) ;
}
}
static uint32_t gBlinkLedDate = 0 ;
static uint32_t gReceivedFrameCount = 0 ;
static uint32_t gSentFrameCount = 0 ;
byte msg[8] = {0, 0, 0, 0, 0, 0, 0, 0};
void loop() {
byte msg[8] = { 12, 23, 33, 44, 55, 66, 77, 28};
CANMessage frame ;
frame.id = 31 ;
frame.ext = true ;
frame.rtr = false ;
frame.idx = 0 ;
frame.len = 8 ;
for (int i=0 ; i<8 ; i++) {
frame.data [i] = {msg[i]} ;
}
/* frame.data [0] = {egt[1]} ;
frame.data [1] = {egt[2]} ;
frame.data [2] = 33 ;
frame.data [3] = 44 ;
frame.data [4] = 55 ;
frame.data [5] = 66 ;
frame.data [6] = 77 ;
frame.data [7] = 88 ;
*/
if (gBlinkLedDate < millis ()) {
gBlinkLedDate += 50 ;
digitalWrite (LED_BUILTIN, !digitalRead (LED_BUILTIN)) ;
const bool ok = can.tryToSend (frame) ;
if (ok) {
gSentFrameCount += 1 ;
Serial.print ("Sent: ") ;
Serial.println (gSentFrameCount) ;
}else{
Serial.println ("Send failure") ;
}
}
}
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#20>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AEWKZVC2CPKH5SHVN6EBNPTSIYE7HANCNFSM4SB6UJNA>.
|
Hi , thanks for the fast reply, Hi , the message sending stops after 17 times. How can I get "gSentFrameCount" in my message , for example in the first byte form my previous sketch ? ` byte msg[8] = { gSentFrameCount, 22, 33, 44, 55, 66, 77, 28}; CANMessage frame ; |
Hi, < static const byte MCP2515_CS = 10 ; // CS input of MCP2515 (adapt to your design) ACAN2515 can (MCP2515_CS, SPI, MCP2515_INT) ; static const uint32_t QUARTZ_FREQUENCY = 8UL * 1000UL * 1000UL ; // 8 MHz void setup() { Serial.begin (38400) ; while (!Serial) { ACAN2515Settings settings (QUARTZ_FREQUENCY, 500UL * 1000UL) ; // CAN bit rate 500 kb/s void loop() { CANMessage frame ; if (gBlinkLedDate < millis ()) { |
Hi,
How can I get "gSentFrameCount" in my message , for example in the first byte form my previous sketch ?
byte msg[8] = { gSentFrameCount, 22, 33, 44, 55, 66, 77, 28}
Yes, it is valid. Note that a gSentFrameCount is an uint32_t, so it is implicitly casted to a uint8_t ; so you send the count modulo 256. You can make the cast explicit:
byte msg[8] = { uint8_t (gSentFrameCount), 22, 33, 44, 55, 66, 77, 28}
Pierre
… Le 3 oct. 2020 à 11:35, Mplex72 ***@***.***> a écrit :
Hi , thanks for the fast reply,
Hi , the message sending stops after 17 times.
I receive the data on the other CANlogger
so it sends the message 17 times , then it stops sending the messages.
How can I get "gSentFrameCount" in my message , for example in the first byte form my previous sketch ?
`
void loop() {
byte msg[8] = { gSentFrameCount, 22, 33, 44, 55, 66, 77, 28};
CANMessage frame ;
frame.id = 31 ;
frame.ext = true ;
frame.rtr = false ;
frame.idx = 0 ;
frame.len = 8 ;
for (int i=0 ; i<8 ; i++) {
frame.data [i] = msg[i] ;
}
`
Thanks , Klass
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#20 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AEWKZVDEGXFIU7P4N7MIF2TSI3V7RANCNFSM4SB6UJNA>.
|
Hi,
Does the LED_BUILTIN stop blinking ?
Pierre
… Le 3 oct. 2020 à 12:14, Mplex72 ***@***.***> a écrit :
Hi,
in fact , after better testingit it sending the message only once !
So probably it does not see an ACK ( the data logger is listen only? )
I see the first message on the logger ! , then it stops sending
<
/*
*
*/
#include <ACAN2515.h>
static const byte MCP2515_CS = 10 ; // CS input of MCP2515 (adapt to your design)
static const byte MCP2515_INT = 3 ; // INT output of MCP2515 (adapt to your design)
ACAN2515 can (MCP2515_CS, SPI, MCP2515_INT) ;
static const uint32_t QUARTZ_FREQUENCY = 8UL * 1000UL * 1000UL ; // 8 MHz
void setup() {
Serial.begin (38400) ;
while (!Serial) {
delay (50) ;
digitalWrite (LED_BUILTIN, !digitalRead (LED_BUILTIN)) ;
}
SPI.begin () ;
ACAN2515Settings settings (QUARTZ_FREQUENCY, 500UL * 1000UL) ; // CAN bit rate 500 kb/s
const uint16_t errorCode = can.begin (settings, [] { can.isr () ; }) ;
if (errorCode == 0) {
Serial.print ("Bit Rate prescaler: ") ;
Serial.println (settings.mBitRatePrescaler) ;
Serial.print ("Propagation Segment: ") ;
Serial.println (settings.mPropagationSegment) ;
Serial.print ("Phase segment 1: ") ;
Serial.println (settings.mPhaseSegment1) ;
Serial.print ("Phase segment 2: ") ;
Serial.println (settings.mPhaseSegment2) ;
Serial.print ("SJW: ") ;
Serial.println (settings.mSJW) ;
Serial.print ("Triple Sampling: ") ;
Serial.println (settings.mTripleSampling ? "yes" : "no") ;
Serial.print ("Actual bit rate: ") ;
Serial.print (settings.actualBitRate ()) ;
Serial.println (" bit/s") ;
Serial.print ("Exact bit rate ? ") ;
Serial.println (settings.exactBitRate () ? "yes" : "no") ;
Serial.print ("Sample point: ") ;
Serial.print (settings.samplePointFromBitStart ()) ;
Serial.println ("%") ;
}else{
Serial.print ("Configuration error 0x") ;
Serial.println (errorCode, HEX) ;
}
}
static uint32_t gBlinkLedDate = 0 ;
static uint32_t gReceivedFrameCount = 0 ;
static uint32_t gSentFrameCount = 0 ;
byte msg[8] = {0, 0, 0, 0, 0, 0, 0, 0};
void loop() {
uint32_t timehack = millis();
byte msg[8] = { timehack >> 24, timehack >> 16, timehack >> 8, timehack & 0xF, 55, 66, 77, 28};
CANMessage frame ;
frame.id = 31 ;
frame.ext = true ;
frame.rtr = false ;
frame.idx = 0 ;
frame.len = 8 ;
for (int i=0 ; i<8 ; i++) {
frame.data [i] = msg[i] ;
}
if (gBlinkLedDate < millis ()) {
gBlinkLedDate += 50 ;
digitalWrite (LED_BUILTIN, !digitalRead (LED_BUILTIN)) ;
const bool ok = can.tryToSend (frame) ;
if (ok) {
gSentFrameCount += 1 ;
Serial.print ("Sent: ") ;
Serial.println (gSentFrameCount) ;
}else{
Serial.println ("Send failure") ;
}
}
}
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#20 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AEWKZVCSN2HKA5BOY7BTRXTSI32QNANCNFSM4SB6UJNA>.
|
Hi , |
Hi,
Perhaps you have a RAM overflow, Arduino has only 2kbytes. Try to have lower sizes hor driver buffers :
ACAN2515Settings settings (QUARTZ_FREQUENCY, 500UL * 1000UL) ;
settings.mTransmitBuffer0Size = 1 ; // >= 0
settings.mReceiveBufferSize = 1 ; // >= 0
const uint16_t errorCode = can.begin (settings, [] { can.isr () ; }) ;
The code can not broadcast Can messages without ACK ?
Unfortunatly no, he MCP2515 does not provide such a feature.
Best Regards,
Pierre
… Le 8 oct. 2020 à 14:26, Mplex72 ***@***.***> a écrit :
Hi ,
Indeed it also stops blinking ,
No further idea as I have already tried another arduino and CANboard.
The code can not broadcast Can messages without ACK ?
Klass
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#20 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AEWKZVCGGZCPKBTIWY3TSULSJWVWTANCNFSM4SB6UJNA>.
|
ok , will try that first , |
Hello,
Fregus Duncan finds a bug in the tryToSend method. I have fixed it and made a new release (2.0.6). Hope this can help.
Pierre
… Le 8 oct. 2020 à 14:41, Mplex72 ***@***.***> a écrit :
ok , will try that first ,
I even think I have a Mega somewhere .
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#20 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AEWKZVHGQZZRDFIHOIRUSLDSJWXN7ANCNFSM4SB6UJNA>.
|
Hi , |
`/* static const byte MCP2515_CS = 10 ; // CS input of MCP2515 (adapt to your design) ACAN2515 can (MCP2515_CS, SPI, MCP2515_INT) ; static const uint32_t QUARTZ_FREQUENCY = 16UL * 1000UL * 1000UL ; // 8 MHz void setup() { Serial.begin (38400) ; while (!Serial) { ACAN2515Settings settings (QUARTZ_FREQUENCY, 500UL * 1000UL) ; void loop() { CANMessage frame ; if (gBlinkLedDate < millis ()) { |
Hi , problem found ,
|
See the pdf doc section 6.4. Without interrupt you must receive using the poll() method. |
Ah , should have seen that, |
What did I do wrong within this sketch on arduino UNO?
it will send only 17 meassages , then I have "failure" in the serial interface .
<
/*
*
*/
#include <ACAN2515.h>
static const byte MCP2515_CS = 10 ; // CS input of MCP2515 (adapt to your design)
static const byte MCP2515_INT = 3 ; // INT output of MCP2515 (adapt to your design)
ACAN2515 can (MCP2515_CS, SPI, MCP2515_INT) ;
static const uint32_t QUARTZ_FREQUENCY = 8UL * 1000UL * 1000UL ; // 8 MHz
void setup() {
Serial.begin (38400) ;
while (!Serial) {
delay (50) ;
digitalWrite (LED_BUILTIN, !digitalRead (LED_BUILTIN)) ;
}
SPI.begin () ;
ACAN2515Settings settings (QUARTZ_FREQUENCY, 500UL * 1000UL) ; // CAN bit rate 500 kb/s
const uint16_t errorCode = can.begin (settings, [] { can.isr () ; }) ;
if (errorCode == 0) {
Serial.print ("Bit Rate prescaler: ") ;
Serial.println (settings.mBitRatePrescaler) ;
Serial.print ("Propagation Segment: ") ;
Serial.println (settings.mPropagationSegment) ;
Serial.print ("Phase segment 1: ") ;
Serial.println (settings.mPhaseSegment1) ;
Serial.print ("Phase segment 2: ") ;
Serial.println (settings.mPhaseSegment2) ;
Serial.print ("SJW: ") ;
Serial.println (settings.mSJW) ;
Serial.print ("Triple Sampling: ") ;
Serial.println (settings.mTripleSampling ? "yes" : "no") ;
Serial.print ("Actual bit rate: ") ;
Serial.print (settings.actualBitRate ()) ;
Serial.println (" bit/s") ;
Serial.print ("Exact bit rate ? ") ;
Serial.println (settings.exactBitRate () ? "yes" : "no") ;
Serial.print ("Sample point: ") ;
Serial.print (settings.samplePointFromBitStart ()) ;
Serial.println ("%") ;
}else{
Serial.print ("Configuration error 0x") ;
Serial.println (errorCode, HEX) ;
}
}
static uint32_t gBlinkLedDate = 0 ;
static uint32_t gReceivedFrameCount = 0 ;
static uint32_t gSentFrameCount = 0 ;
byte msg[8] = {0, 0, 0, 0, 0, 0, 0, 0};
void loop() {
byte msg[8] = { 12, 23, 33, 44, 55, 66, 77, 28};
CANMessage frame ;
frame.id = 31 ;
frame.ext = true ;
frame.rtr = false ;
frame.idx = 0 ;
frame.len = 8 ;
for (int i=0 ; i<8 ; i++) {
frame.data [i] = {msg[i]} ;
}
/* frame.data [0] = {egt[1]} ;
frame.data [1] = {egt[2]} ;
frame.data [2] = 33 ;
frame.data [3] = 44 ;
frame.data [4] = 55 ;
frame.data [5] = 66 ;
frame.data [6] = 77 ;
frame.data [7] = 88 ;
*/
if (gBlinkLedDate < millis ()) {
gBlinkLedDate += 50 ;
digitalWrite (LED_BUILTIN, !digitalRead (LED_BUILTIN)) ;
const bool ok = can.tryToSend (frame) ;
if (ok) {
gSentFrameCount += 1 ;
Serial.print ("Sent: ") ;
Serial.println (gSentFrameCount) ;
}else{
Serial.println ("Send failure") ;
}
}
}
The text was updated successfully, but these errors were encountered: