This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Writing a gg file using the bqTools SDK

Other Parts Discussed in Thread: BQSTUDIO, BQ40Z50

I have been not able to successfully write a gg file with the TI bqToolsSDK. Specifically, using this function below within bqSBB.dll. I am speculating there is a dependency I am unaware of and it is not documented. I call the function and it writes the file with only the header information. None of the gg parameters are written to the file and no errors are returned. Any help would be appreciated. I've tried the WriteGGFile and WritePublicGGFile functions and get the same result.

int WritePublicGGFile ( const char *  dataPipeName,
const char *  fileName,
char  delimiter,
int  format 
)

Write public parameters to a gg file.

Data in data flash buffer will be written to device first if required. File will be overwritten if it existing.

Parameters:
dataPipeName Data Pipe Name
fileName File name
delimiter Field delimiter
format Output format 1 = All Fields, 2 = Debug, 3 = Classic GG Format, 4 = Default bcfgx.
Returns:
Zero for success. Non-zero for erro
  • Hello,

    I'm searching for documentation and some examples on how to use the bqTools SDK.

    Is it compatible with "the good old" VB6 ?

    Pietro

  • You should be able to use VB6, the SDK is a collection of C DLLs. You would need to use the Lib keyword and declare all the functions in the SDK you intend to use. If you decide to move to the 21st century and use a .Net language ;-) , you can use PInvoke ( Platform Invoke).

    VB6 Example (Note: This example would depend on the DLL "SomeSDK.dll be registered in the Windows Registry):

    Declare Function GetSerialNumber Lib "SomeSDK.dll" ( ByVal GetSN As String) As Integer

    To use this to get the SN and populate a textbox you would do something like this:

    Sub PopSerialNum

    Dim SN as String = ""

    Dim ErrorCode as Integer

    ErrorCode = GetSerialNumber(SN)

    If ErrorCode = 0 then

    Me.txtSN.txt = SN

    Else

    Me.txtSN.txt = "Error"

    End If

    End Sub

  • To close this write a gg file using the SDK is to use the following three functions in sequence. The part I did not see at first was I needed to load the proper container file for the chip I was using. In my case, "4500_1_06-bq40z50_r1.bqz."

    'Unmanaged DLL code:
    ' /*! \fn int OpenContainerInitDLL(const char *dataPipeName, const char *containerName)
    ' \brief This function opens the container and loads all parameter information into internal data structures.
    ' \param dataPipeName Name of data pipe to use for communication.
    ' \param containerName Path to container file. Full path is recommended. Path is relative to the application directory.
    ' \return Zero for success. Non-zero for error or warning.
    '*/
    'extern BQSBB_CAPI int CALLCONV OpenContainerInitDLL(const char *dataPipeName, const char * containerName);
    <DllImport("bqSBB.dll", CallingConvention:=CallingConvention.Cdecl, EntryPoint:="OpenContainerInitDLL")> _
    Public Function bqSBB_OpenContainerInitDLL(ByVal dataPipeName As String, containerName As String) As Integer
    End Function

    'Unmanaged DLL code:
    ' /*! \fn int RefreshAllData(const char * dataPipeName)
    ' \brief This will read rows 0 to MAXDFSIZE/32 from device and copy into the internal buffer inside this component. MAXDFSIZE is 8192
    ' \param dataPipeName Name of data pipe to use for communication.
    ' \return Zero for success. Non-zero for error or warning.
    '*/
    'extern BQSBB_CAPI int CALLCONV RefreshAllData(const char *dataPipeName);
    <DllImport("bqSBB.dll", CallingConvention:=CallingConvention.Cdecl, EntryPoint:="RefreshAllData")> _
    Public Function bqSBB_RefreshAllData(ByVal dataPipeName As String) As Integer
    End Function

    'Unmanaged DLL code:
    ' /*! \fn int WriteGGFile(const char *dataPipeName, const char *fileName, char delimiter, int format)
    ' \brief Write all parameters to a gg file. Data in data flash buffer will be written to device first if required.
    ' File will be overwritten if it existing.
    ' \param dataPipeName Data Pipe Name
    ' \param fileName File name
    ' \param delimiter Field delimiter
    ' \param format Output format 1 = All Fields, 2 = Debug, 3 = Classic GG Format, 4 = Default bcfgx.
    ' \return Zero for success. Non-zero for error
    '*/
    'extern BQSBB_CAPI int CALLCONV WriteGGFile(const char *dataPipeName, const char *fileName, char delimiter, int format);
    <DllImport("bqSBB.dll", CallingConvention:=CallingConvention.Cdecl, EntryPoint:="WriteGGFile")> _
    Public Function bqSBB_WriteGGFile(ByVal dataPipeName As String, ByVal FileName As String, <[In]> ByVal Delimiter As System.Byte, ByVal Format As Integer) As Integer
    End Function
  • Thanks Pete,
    very informative.
    So from your notes, I understand that bqSBB API is used to automate same the operations you normally do through bqstudio, correct ?

    Reading the various functions, I'm more interested to have a lower level access to the register and the data memory, as described by the CMAPI.h functions. This approach better refelct a set of tools we have already made to work with an older bq product still using EV2300 and bq80xRW.ocx.
    Do youhave some documentation or experience using the CMAPI.dll ?

    Pietro
  • Pietro,

    There are three seperate DLLs in the SDK. All three need to be used in order to cover all the functions in bqStudio. I just included which ones are used to save a gg file from my original post.

    The three DLLs are: bq80XRW.dll, bqSBBpub.dll and CMAPI.dll. You also need to use commgr.exe to setup the command and data pipes for CMAPI.dll. There is an example C program in the SDK that demonstrates a programming and calibration sequence and it uses the Com Manager.

    I actually created a complete .Net wrapper API for the SDK for convenience. All of the functions in all three APIs are available in the one .Net dll class. It makes is a lot simpler when creating test applications for production testers, etc.

    -Pete
  • Thanks for the info.

    I will focus on the CMAPI dll because the readblock/Writeblock operations are those we need to manage.

    I checked my SDK and found no ".c" source file, in the various subfolder: can you eventually share the example program ?

    Regards

    Pietro

  • If you installed the SDK with the TI installer, the example will be in C:\TI\bqToolsSDKb20150417\SampleCode\bq40z50_VS2010_ToolsSDK.

    If you do not have the TI SDK installer, contact your TI rep. There are a few different examples and documentation to help your development.

    -Pete
  • Thanks Pete, now I understand:
    I just received a zipped version, without any installer and any sample code.
    I will ask for a full installable version.

    On the other side I successfully managed to access the DF with the low level functions of bq80xRW.ocx, and so I can send MAC commands and Read/Write blocks of DF.

    Pietro
  • Dear Pietro,

    Did you receive a zipped version with code? Is a version available? I would also be interested in the SDK for automating the download form the commandline for production automation.

    Can somebody please point me in the right direction?

    Thanks and best regards,

    Bjoern

  • Bjoern,
    it sounds a bit too complicated for me to study that SDK, I did not have all the time it deserve.

    Rather, I preferred a simpler approach that I already used many years ago with another bq gas gauge.
    I access directly to the DF table with the SBS Read and Write commands and the BlockRead - BlockWrite commands available from the bq80xRW.ocx

    I understand that the the valid DF from 0x4000 to 0x497F can be easily read/written in pages of 32bytes each, and allso all the MAC commands can be easily sent following the examples written in the tech ref.

    In this way I only need to keep a DB with all the version of my DF settings and apply to the batteries in production base don the model/version.

    Hope this helps
    Pietro
  • Pietro-
    Thanks for your quick reply and your clarification. I would definitely like to go with the SDK.

    However, I have problems finding the representative in charge which I can contact for the SDK.

    Regards,

    Bjoern
  • Bjoern,

    You might try contacting Tom Cosby, he is a TI Application Engineer. He is very knowledgeable and helpful. You can find his contact info. on the forum. He should be able to connect you to the right person.

    -Pete
  • Hi Bjoern,
    Let me contact you offline on this.
    Regards,
    Swami