[Ovmsdev] CAN transmit problems - Think City vehicle_thinkcity.c

Mark Webb-Johnson mark at webb-johnson.net
Mon Aug 26 08:25:17 HKT 2013


Håkon,

The user controls turning on/off the feature either with SMS (FEATURE 15 1) or via the smartphone apps FEATURES controls.

When your vehicle module initialises, it sets up the CAN controller appropriately. Something like this should already be there in your module:

  if (sys_features[FEATURE_CANWRITE]>0)
    {
    CANCON = 0b00000000;  // Normal mode
    }
  else
    {
    CANCON = 0b01100000; // Listen only mode, Receive bufer 0
    }

Polling for data is fairly common, and you can see some example for how to do it in vehicle_voltampera.c. See vehicle_voltampera_ticker1I() for the transmission of the poll request, and vehicle_voltampera_poll0() for the reception of the response.

Regards, Mark.

On 26 Aug, 2013, at 3:59 AM, Håkon Markussen <hakon.markussen at gmail.com> wrote:

> Hi,
> 
> I've met a problem to which I need some help.
> 
> I need to request some parameters from one ECU, and try to transmit on the can-bus from the OVMS-module.
> Whatever I do, the sys_features[FEATURE_CANWRITE] is always "0" and the transmission will never take place.
> 
> I have tried to set the sys_features[FEATURE_CANWRITE] to "1", but as explained in the dev-doc, the TXB0CONbits.TXREQ will never go true and the module will reboot.
> 
> The receiver of the request (RX-part) works fine, I've tested that by transmitting manually with PCANView.
> I have tried to put the TX-statements in the poll1, ticker1 and currently; in an idle poll (as in vehicle.teslaroadster.c) which has a hook in 
> vehicle_fn_idlepoll = &vehicle_thinkcity_idlepoll;
> 
> I've debugged a bit and found that:
> FEATURE_CANWRITE = 15
> sys_features[FEATURE_CANWRITE] = 0 
> right before the if-test begin.
> 
> I would be happy if anyone have some helpful hints :-)
> 
> 
> BOOL vehicle_thinkcity_idlepoll(void)
> {
>   if (sys_features[FEATURE_CANWRITE]>0)
>   {
>     while (TXB0CONbits.TXREQ) {} // Loop until TX is done
>     TXB0CON = 0;
>     TXB0SIDL = 0b01100000;  // msg 753 03 22 49 67
>     TXB0SIDH = 0b11101010;
>     TXB0D0 = 0x03;
>     TXB0D1 = 0x22;
>     TXB0D2 = 0x49;
>     TXB0D3 = 0x67;
>     TXB0DLC = 0b0000100; // data length (4)
>     TXB0CON = 0b00001000; // mark for transmission
>   }
> return FALSE;
> }
> 
> 
> Best regards
> Håkon
> _______________________________________________
> OvmsDev mailing list
> OvmsDev at lists.teslaclub.hk
> http://lists.teslaclub.hk/mailman/listinfo/ovmsdev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvehicles.com/pipermail/ovmsdev/attachments/20130826/bc2641ef/attachment.htm>


More information about the OvmsDev mailing list