Difference: DTCLibrary (5 vs. 6)

Revision 626 Jul 2010 - MichaelDimitriyev

Line: 1 to 1
 
META TOPICPARENT name="DTCSoftware"
The DTC library, dtcreg, contains a set of functions that facilitate reading from and writing to registers on the DTC.
Added:
>
>
A detailed account of updates may be found in the Readme file at [http://cms1.bu.edu/~msdim/dtc_software/].
 

Opening and Closing

The code may be found in /home/msdim/ipmi/ipmitool-1.8.11/dtcreg, where dtcreg.o is the actual library and dtcreg.h is the associated header file.

Line: 45 to 47
 

Reading and Writing

Changed:
<
<
There are 16 read/write functions. However, all of the functions come in two variations, so in truth, there are only 8 distinct functions. All of the functions ask for the handle as the first parameter and all return an error code. The second parameter is always a register address. However, there are two ways to enter the address: as an integer or as a string. The integer form is more useful if the functions are in, say, a "for" loop which runs through a number of registers. The string form is useful as register addresses are typically hexadecimal and look something like "0x2c". Therefore, each of the 6 distinct functions has an integer version and a hexadecimal-string version. Since the hexadecimal version is simply a wrapper function that calls the integer version with a translated parameter, the function name acquires an 'x' near the end, so the hexadecimal addressed version of dtc_read(...) is dtc_readx(...).
>
>
There are 4 read and 4 write functions. As of version 3, each of these functions requires a pointer to a hDTC handle for the first parameter and a register address for the second. Prior to version 3, each function required the actual handle to be passed. The requrement of a pointer to the handle arises from the need to change values stored in the struct. Version 3 fixes a timeout problem: after one minute, the connection would timeout and the read and write functions were useless after. Now, if dtc_read/dtc_write fails, the function closes the handle and attempts to re-open it: if the re-open is successful, then the read/write is performed; else, the handle is simply closed to avoid future attempted operations on a closed connection. Furthermore, version 3 removes the dtc_readx/dtc_writex variations: they simply required a string register address rather than a numeric register address which made console input simpler. To convert strings composed of numbers, either in plain notation ("109") or in hexadecimal notation ("0x2c"), the following standard function should be used:

strtoul(char *str, NULL, 0);  // "string to unsigned long"

Note that the byte number variations (dtc_read## and dtc_write##) call dtc_read() and dtc_write() for their reading/writing operations. Therefore, any major "low level" hardware interface changes will be made in the dtc_read() and dtc_write() functions and should carry through to their variants.

  dtc_read/dtc_write

These are the most basic read and write functions and are called by the higher level read/write functions. dtc_read reads from one register and dtc_write writes to one register.

Changed:
<
<
int dtc_read(hDTC handle, int regAddr, uint8_t dat[], int *lenRead) / dtc_readx(..., char *hexRegAddr, ..., ...)
>
>
int dtc_read(hDTC *handle, int regAddr, uint8_t dat[], int *lenRead)
  The third parameter asks for an array of 8-bit unsigned integers which will contain the read data. The fourth parameter asks for the address of an integer in which the length of the read data will be stored, i.e. the length of the data array. The max array length that this (and all following functions) assumes is defined by MAX_DATA in dtcreg.h and is by default set to 16.
Changed:
<
<
int dtc_write(hDTC handle, int regAddr, uint8_t dat) / dtc_writex(..., char *hexRegAddr, ...)
>
>
int dtc_write(hDTC *handle, int regAddr, uint8_t dat)
  This is a simple function: the third parameter is the 8-bit value to write to the register.
Line: 68 to 75
  Specialized for reading from 8-bit registers and 32-bit registers (four subsequent 8-bit registers). Can also read from a number of subsequent registers.
Changed:
<
<
int dtc_read8(hDTC handle, int regAddr, uint8_t dat[], int count) / dtc_readx8(..., char *hexRegAddr, ..., ...)
>
>
int dtc_read8(hDTC *handle, int regAddr, uint8_t dat[], int count)
  The third parameter requires an array which will hold the amount of data specified by count, which specifies the number of subsequent registers to read (count = 1 reads one).
Changed:
<
<
int dtc_read32(hDTC handle, int regAddr, uint32_t dat[], int count) / dtc_readx32(..., char *hexRegAddr, ..., ...)
>
>
int dtc_read32(hDTC *handle, int regAddr, uint32_t dat[], int count)
  Here, count refers to the number of 32-bit registers to read from, that is, 4*count will be the total number of 8-bit registers to be read.
Line: 83 to 94
  Similar to dtc_read8/dtc_read32.
Changed:
<
<
int dtc_write8(hDTC handle, int regAddr, uint8_t dat[], int count) / dtc_writex8(..., char *hexRegAddr, ..., ...)
>
>
int dtc_write8(hDTC *handle, int regAddr, uint8_t dat[], int count)
  Takes an array of data in the third argument and writes to a number of subsequent registers specified by count. So, dat[0] is written to the register specified by regAddr, dat[1] is written to regAddr+1, ..., dat[count-1] is written to regAddr+count-1.
Changed:
<
<
int dtc_write32(hDTC handle, int regAddr, uint32_t dat[], int count) / dtc_writex32(..., char *hexRegAddr, ..., ...)
>
>
int dtc_write32(hDTC *handle, int regAddr, uint32_t dat[], int count)
  dat[0] is written to registers regAddr through regAddr+3, dat[1] is written to regAddr+4 through regAddr+7, ..., dat[count-1] is written to regAddr+4*(count-1) through regAddr+4*(count-1)+3.
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback