Skip to content
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

Can receive returns empty bytes, Can send doesnt send. #145

Closed
illegal-instruction-co opened this issue Jun 16, 2023 · 2 comments
Closed
Assignees
Labels
Seeed_Arduino_CAN Label for Seeed_Arduino_CAN UAY Unassigned yet

Comments

@illegal-instruction-co
Copy link

I have got UNO R3 ( original one ) and seeed studio can shield v2.

This is my code:

#include "Config.h"

#include "Components/Logger.h"
#include "Components/Can.h"

#include <SPI.h>

namespace ii::blackbox::components {

void Can::SetUp() {
	// m_canSend.setMode(CAN_NORMAL_MODE);
	// m_canSend.setMode(CAN_NORMAL_MODE);

	while (m_canSend.begin(CAN_500KBPS) != CAN_OK && m_canReceive.begin(CAN_500KBPS) != CAN_OK) {
#ifdef SERIAL_DEBUG
		SERIAL_PORT_MONITOR.println("CAN init fail, retry...");
#endif
		delay(100);
	}

#ifdef SERIAL_DEBUG
	SERIAL_PORT_MONITOR.println("CAN init OK.");
#endif
}

unsigned char len = 0;
unsigned char buf[8];

void Can::Loop() {
	// ---------------------

	if (CAN_MSGAVAIL == m_canReceive.checkReceive()) {
		// read data,  len: data length, buf: data buf
		SERIAL_PORT_MONITOR.println("checkReceive");
		m_canReceive.readMsgBuf(&len, buf);
		// print the data
		SERIAL_PORT_MONITOR.print("ID: ");
		SERIAL_PORT_MONITOR.print(m_canReceive.getCanId());
		SERIAL_PORT_MONITOR.print("  DLC: ");
		SERIAL_PORT_MONITOR.print(len);
		for (int i = 0; i < len; i++) {
			// SERIAL_PORT_MONITOR.print(buf[i]);
			// SERIAL_PORT_MONITOR.print(" ");
		}
		SERIAL_PORT_MONITOR.println();
	}
	SERIAL_PORT_MONITOR.println("---LOOP END---");
}

} // namespace ii::blackbox::components

and here is the response:

checkReceive
ID: 536870911  DLC: 255
---LOOP END---
checkReceive
ID: 536870911  DLC: 255
---LOOP END---
checkReceive
ID: 536870911  DLC: 255
---LOOP END---
checkReceive
ID: 536870911  DLC: 255
---LOOP END---
checkReceive
ID: 536870911  DLC: 255
---LOOP END---
checkReceive
ID: 536870911  DLC: 255
---LOOP END---
checkReceive
ID: 536870911  DLC: 255
---LOOP END---
checkReceive
ID: 536870911  DLC: 255
---LOOP END---
checkReceive
ID: 536870911  DLC: 255
---LOOP END---
checkReceive
ID: 536870911  DLC: 255
---LOOP END---
checkReceive
ID: 536870911  DLC: 255
---LOOP END---
checkReceive
ID: 536870911  DLC: 255
---LOOP END---
checkReceive
ID: 536870911  DLC: 255

I tried D9 - D2 / D9 - D10

but its still same result.

Im plugging my shield on my r3 directly.

@MatthewJeffson MatthewJeffson added UAY Unassigned yet Seeed_Arduino_CAN Label for Seeed_Arduino_CAN labels Oct 9, 2024
@Lesords Lesords self-assigned this Oct 14, 2024
@Lesords
Copy link
Contributor

Lesords commented Oct 16, 2024

Hello,

I'm very sorry to have kept you waiting so long.

Do you still have this problem now?

@Lesords
Copy link
Contributor

Lesords commented Nov 4, 2024

Hello,

I'm going to close this issue, feel free to re-open it if you have any other questions.

[Autocommentary]

@Lesords Lesords closed this as completed Nov 4, 2024
@github-project-automation github-project-automation bot moved this from Todo to Done in Issues and PR Assemble Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Seeed_Arduino_CAN Label for Seeed_Arduino_CAN UAY Unassigned yet
Projects
Status: Done
Development

No branches or pull requests

3 participants