collin80 / GEVCU6

Generalized Vehicle Control Unit for version 6 boards
MIT License
25 stars 14 forks source link

CAN transmission of extended messages is not working #5

Closed bsculley closed 5 years ago

bsculley commented 5 years ago

I have gotten CAN messaging working now. I am able to communicate between GEVCU and the PowerKey Pro. I am monitoring the CAN traffic with a teensy using a SN65HVD230D tranceiver and the FlexCAN_Library. I can see the button presses from the PowerKey and the GEVCU response to set the LEDS.

What is not working is sending extended frames. Here is the routine that sends the frame:

bool FaradayMotorController::getBaseValues(int motor) {

  CAN_FRAME requestFrame;
  bool result;

  uint8_t buf[] = {0x0A, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  requestFrame.extended = 1; //J1939 frame
  requestFrame.fid = 0; //?
  requestFrame.priority = 7;
  requestFrame.rtr = 0;
  requestFrame.length = 3;
  uint32_t i = 0xEA00 + motor;
  requestFrame.id = (i << 8) + 0xF9; 
  memcpy(requestFrame.data.bytes, buf, 8);

  result = canHandlerEv.sendFrame(requestFrame);

  Logger::info("info request sent: %X result %d ", motor, result);
  return true;
}

Here is the CanHandler sendFrame routine:

bool CanHandler::sendFrame(CAN_FRAME& frame) 
{   
  logFrame(frame);   
  return bus->sendFrame(frame);
}

Here is the serial output on GEVCU:

32867 - INFO: CAN: ext=0x1 rtr=0x0 pri=0x7 fid=0x0 id=0xEA00F9 len=3 data=0xA,0xFF,0x0,0x0,0x0,0x0,0x0,0x0
32871 - INFO: info request sent: 0x0 result 1 

Everything appears to be working. No errors and a good return from bus->sendFrame, but nothing shows up on the wire.
When I change the extended setting to 0 (no other changes), then I can see the frame, although somewhat mangled. Output from the serial port on the teensy:

CAN 0: ext=0 rtr=0 pri=0 id=F9 len=3 0a ff 00 It appears that there are issues with the extended frames. What is the "family id" is this something I should be using with extended frames?

I Considered replacing the due_can library with FlexCAN, but I'm not sure how big a "can" of worms that would be.

As always, any help will be greatly appreciated.

Bob

bsculley commented 5 years ago

Sorry. Turned out I wasn't receiving the extended frames.