Help with _write_spi() and _read_spi() for daughterboard driver

I am writing a driver for a daughterboard and using the methods
_write_spi() and _read_spi() to write and read on to the daughterboard
registers. The write operation is as follows.

usrp()->_write_spi(hdr, spi_enable, spi_format,s)

hdr : 16 bits (15th bit - r/w, bits 1-14 - register address, 0th bit-
auto increment) //This format is specified in the daughterboard

s : Data to be written on the selected register. Data type is std::

Reading the data from the daugherboard is as follows.

  1. Whichever is the last register on which data is written, data can be
    read off starting from that particular address using the following.

r = usrp()->_read_spi(hdr,enables, format, length) //I take the hdr as
0 here(equivalent to no header since it is not needed)

Now the size of the register is 1 byte.
char c[1];
c[0] = (char)(dat & 0xff) // dat is the value that needs to be written
to the resister. Values are between 0 and 255
std::string s(c,1); //I send this value of s to the write_spi function
that I have mentioned above/

So here is the summary of what I do to check if the register is being
written correctly or not.

  1. Write register number 5 say
  2. Write register 0
  3. Read the first 10 bits say in string r.
    But I am get an empty string. Is my preparation of string s correct?

Also can somebody tell me if whether I am making a mistake with the
read or the write?

Thank you

Sriram Krishnan

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs