Config_parser.c Unkown Parameter

Hi there,

I am working with the newest version of the Toradex Libraries that we received on one of our support tickets:
ToradexCeLibraries_2.1b4327-20180226

I am attempting to look at input and output on a Logic Analyzer on the CAN bus. I am hooked up to the external can interface with the jumpers JP4 and JP5 removed and jumping from the X38 terminal to SODIMM 63 and 55 to line up with the Colibri specific pins. I have a Can bus analyzer hooked up to the CAN terminal and am sending repeated RX signals.

I’ve been trying to verify the pin setup by using the CAN demo provided in the Toradex Libraries. I’ve edited the can_demo.c file to reflect the IMX6 CAN calls and pin setup.

But now I receive this error when I try to pass in parameters to Imx6Can_setConfigInt(…):
Like so:

CAN Error: .\src\config_parser.c, 325: Unknown parameter "ioRx"

I’ve tried pretty much every parameter and get the same message.

How should I go about fixing this? Do you see anything wrong with my edits to can_demo.c?

//
/// @file         Can_Demo.c
/// @copyright    Copyright (c) 2014 Toradex AG
/// $Author: samuel.bissig $
/// $Rev: 4320 $
/// $Date: 2018-02-19 15:23:39 +0530 (Mon, 19 Feb 2018) $
/// @brief        Program to show how to use CAN library
///               A CAN transceiver is required. Colibri Evaluation Board V3.2 provides the facility to use
///               on board CAN transceiver, refer its datasheet for more details.
/// @target       Colibri VFxx Modules
/// @test         Tested on: VFxx
/// @caveats      None
///

#include <windows.h>
//Uncomment the line below if you want to use TdxAllLibrariesDll.dll
//#define USE_DLL
#include "can_imx6.h"
#include "coproc.h"
#include "gpio.h"

//*****************************************************************************
/// CAN receive process
/// @param[in]  hCan       Handle to CAN channel
DWORD CanRxProcess(HANDLE hCan)
{
    INT i;
    tCanMsg canBuf = {0};
    BYTE data[8] = {0};   // Rx buffer

    // Configure timeout to 5 sec, by default it is set to 1 sec
    Imx6Can_SetConfigInt(hCan, L"Timeout", 5000, StoreVolatile);    // optional

    // 4. Use CAN
    canBuf.dataLen = 8;
    if (Can_Read(hCan, &canBuf))
    {
        printf("\nCAN Receive: Frame ID = 0x%x, Remote/Data Frame = %s %s len %d\n", canBuf.id, (canBuf.canMsgFlags & CanMsgFlags_RTR  ? "REMOTE" :  "DATA"), (canBuf.canMsgFlags & CanMsgFlags_IDE  ? "EXTENDED" : "STANDARD" ), canBuf.dataLen);
        // display received data
        if ((canBuf.canMsgFlags & CanMsgFlags_RTR) == 0)
        {
            printf("Data:");
            for (i = 0; i < 8; i++)
            {
                printf(" %d", canBuf.data[i]);
            }
        }
    }
    else
    {
        printf("\nCAN Receive error\r\n");
    }

    return 0;
}

//*****************************************************************************
/// CAN transmit process
/// @param[in]  hCan       Handle to CAN channel
DWORD CanTxProcess(HANDLE hCan)
{
    INT i;
    tCanMsg canBuf = {0};
    BYTE data[8] = {0, 1, 2, 3, 4, 5, 6, 7};   // Tx buffer

    // 4. Use CAN
    canBuf.id    = rand() & 0x7FF;         // CAN frame ID
    canBuf.canMsgFlags = 0;
    memcpy(canBuf.data, data, sizeof(data));
    canBuf.dataLen = 8;

    if (Can_Write(hCan, &canBuf))
    {
        printf("\nCAN Transmit: Frame ID = 0x%x Remote/Data Frame = %s\nData:", canBuf.id, (canBuf.canMsgFlags & CanMsgFlags_RTR  ? "REMOTE" :  "DATA"));
        // display Transmit data
        for (i = 0; i < 8; i++)
        {
            printf(" %d", canBuf.data[i]);
        }
    }
    else
    {
        printf("CAN Transmit error\r\n");
    }

    return 0;
}


//*****************************************************************************
/// Main function
/// @param[in]  instance       Handle to program instance
/// @param[in]  prevInstance   Handle to previous program instance
/// @param[in]  cmdLine        Command line string pointer
/// @param[in]  cmdShow        Window state
/// @retval     1              Always returned
int WINAPI WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPWSTR cmdLine, int cmdShow)
{
    HANDLE hCan = NULL;
    BOOL isSelectionDone = FALSE;
    INT selectedOption;
    BOOL returnValue = FALSE;
    DWORD busStatus;

	UNREFERENCED_PARAMETER(instance);
	UNREFERENCED_PARAMETER(prevInstance);
	UNREFERENCED_PARAMETER(cmdLine);
	UNREFERENCED_PARAMETER(cmdShow);

    printf("Toradex CAN demo\r\n");

    // 1. Initialize CAN without affecting hardware registers
   // if (Cop_GetFormFactor() == FormFactor_Apalis)
        hCan = Imx6Can_Init(L"CAN1"); // Internal CAN
   // else
     //   hCan = Can_Init(L"SPI1"); // External MCP2515 Controller

    if (hCan == NULL)
    {
        printf("Error in CAN initialization\r\n");
        return FALSE;
    }

    // 2. Change configuration as required
    //    Please refer the documentation regarding the configurations from the .chm file present in the library package.
    //    Instead of calling this function, you can place values in the registry (not present by default). You may use
    //    StoreToRegistry instead of StoreVolatile to configure these values in registry from application for future use.
    //      [HKLM\SOFTWARE\TORADEX\CANx]
    //      Implementation = "VybridCAN"
    //      Interface      = "CAN1"
     {
        uIo ioRx =  COLIBRI_PIN(63);
        uIo ioTx =  COLIBRI_PIN(55);
        Imx6Can_SetConfigInt(hCan, L"ioRx", ioRx.GenericDefinition, StoreToRegistry);
        Imx6Can_SetConfigInt(hCan, L"ioTx", ioTx.GenericDefinition, StoreToRegistry);
    } 
    //returnValue = Can_SetConfigString(hCan, L"FilterFrameFormat",    L"extended",     StoreVolatile);     // Set FilterFrameFormat
    //returnValue = Can_SetConfigString(hCan, L"FilterFrameFormat",    L"standard",     StoreVolatile);     // Set FilterFrameFormat
    //returnValue = Can_SetConfigString(hCan, L"FilterRemote",   L"remote",     StoreVolatile);     // Set FilterRemote to discard remote frames
    //returnValue = Can_SetConfigString(hCan, L"FilterRemote",   L"data",     StoreVolatile);     // Set FilterRemote to discard data frames
    //returnValue = Can_SetConfigInt(hCan, L"FilterID",   0x01,       StoreVolatile);     //
    //returnValue = Can_SetConfigInt(hCan, L"FilterMask", 0x03,       StoreVolatile);     //
    //returnValue = Can_SetConfigInt(hCan, L"SingleThread", 0,       StoreVolatile);     // activate single thread accessing MCP2515

    /*{
        DWORD bitRate;
        printf("Enter CAN bit rate in Hz:");
        scanf_s("%d", &bitRate);
        returnValue = Can_SetConfigInt(hCan, L"BitRateHz", bitRate, StoreVolatile);
    }*/

    // 3. Apply configuration to hardware
	// Note: In a real application you should do this just before you want to receive 
	//       Any data, otherwise the buffer will be already full once you start receiving
    if (!Imx6Can_Open(hCan))
    {
        printf("CAN Open failed\r\n");
        Imx6Can_Deinit(hCan);
        return 0;
    }

    returnValue = Imx6Can_GetConfigInt(hCan, L"BusStatus", &busStatus);
    printf("BusStatus %x\n",busStatus);

    do
    {
        printf("\nOptions:\n");
        printf("1. CAN Transmit   2. CAN Receive   3. Quit\n\n");
        printf("Choose the option and press Enter key: ");
        scanf_s("%d", &selectedOption);
        printf("\n");

        /// Enter only if there is only one character entered from key board.
        switch (selectedOption)
        {
            case 1:
                /// CAN Transmit
                CanTxProcess(hCan);
                break;

            case 2:
                /// CAN Receive
                CanRxProcess(hCan);
                break;

            case 3:
                /// Quits the demo
                isSelectionDone = TRUE;
                break;

            default:
                printf("Invalid entry, try again!\n\n");
                isSelectionDone = FALSE;
        }
    } while (!isSelectionDone);


    /// 5. Close CAN channel
    Imx6Can_Close(hCan);

    /// 6. Deinit CAN channel
    Imx6Can_Deinit(hCan);

    return(TRUE);
}

Dear @chronic788

Your modified code looks perfectly fine. I didn’t test the CAN functionality, but the parameter was accepted without error.
For my test I copy-pasted your code to make sure there is no typo - it works in my installation with both libraries

Can you please test the following stripped-down version of the can_demo:

// Reduced Can Demo
#include <windows.h>
#include "can_imx6.h"
#include "gpio.h"

int WINAPI WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPWSTR cmdLine, int cmdShow)
{
    HANDLE hCan = NULL;
    uIo    ioRx =  COLIBRI_PIN(63);
 
    hCan = Imx6Can_Init(L"CAN1"); // Internal CAN
    Imx6Can_SetConfigInt(hCan, L"ioRx", ioRx.GenericDefinition, StoreToRegistry);
    Imx6Can_Deinit(hCan);
}
  1. Does it work with the preliminary library?
  2. Does it work with the regular V2.1 library?
  3. If you still have issues, try to clear the registry. (Even if I don’t believe this has an impact)

To reproduce your problem, can you please

  • Zip the whole project including libraries, upload it to https://share.toradex.com/ and post the download link here.
  • Which OS are you using (WEC7 / WEC2013)?
  • Which OS version (e.g. V1.3b4) ?
    START → Programs → Colibri Tools → Update Tool [Version Info]
  • Which Visual Studio Version are you using (e.g. VS2015)

Hi there,

I’ve integrated the stripped down code and tested it on the board with both libraries as well as clearing the registry and got the same error.

See the attached screenshot.

Are there further tests we can run to resolve this issue? Is there any further input you need from out end?

Thanks!

-We are using WEC2013.

-The version information is:
Bootloader:

ID: COLIBRI IMX6
Ver. 1.3 BETA, Build 4

Image
ID: COLIBRI IMX6
Ver: 1.3 BETA, Build 4 (CE 8.0)

We are using VS 2015.

Here is the download link:
https://share.toradex.com/ecsq22xy7vwl6gj

Thanks for the help!

@chronic788 ,

Could you please share once again source code. The download is no more valid. Select 3 months validity option while uploading it.

I’ve reuploaded our code here:

https://share.toradex.com/5e399b6svepxrjc

We are concerned that the recent modifications to the libraries to correct other errors with the confic_parser.c file somehow corrupted the ability to set parameters. We are working to debug our main application and we cannot read any values through Imx6Can_Read(…) and we are concerned that this issue is causing the configuration not to take hold in the drivers within the library.

That link I provided turned out to have a corrupt file in it.

Please use this one instead:

https://share.toradex.com/cc5ngdnejvkpves

This is no longer an issue for us. We determined that we had incorrectly configured the project. Rebuilding the project using the correct settings corrected the issue such that the originally posted code works.

Thanks for the help!

@chronic788,
Thank you for posting an update.