picandies
Posts: 122
Joined: Wed Nov 26, 2014 5:13 pm

smbus read_block_data() definition

Tue Sep 25, 2018 1:26 am

WHERE are the parameters for this function described/defined? I need a list of exactly what the needed parameters are. These must be exactly specified in a manual somewhere.

By this I mean: readings=mybus.read_block_data( parameters) ...what are the parameter(s)

Also some example of using it to read 10 bytes into the rpi

DirkS
Posts: 9049
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: smbus read_block_data() definition

Tue Sep 25, 2018 6:58 am

In which language and which module / library?

User avatar
joan
Posts: 13558
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: smbus read_block_data() definition

Tue Sep 25, 2018 7:26 am

I do not think it does what you want. The device specifies the number of returned bytes, not the user.

http://abyz.me.uk/rpi/pigpio/python.htm ... block_data

You probably want read_i2c_block_data

http://abyz.me.uk/rpi/pigpio/python.htm ... block_data

picandies
Posts: 122
Joined: Wed Nov 26, 2014 5:13 pm

Re: smbus read_block_data() definition

Tue Sep 25, 2018 4:17 pm

The device specifies the number of returned bytes, not the user
...this is a standard rpi3 with stretch, using python
import smbus
import sys
import time
bus=smbus.SMBus(1)
get_my_data= bus.read_block_data(WHAT EXACTLY GOES IN HERE)

WHAT are these parameters , please list & describe
I need to read 10 bytes of data to be rcvd

User avatar
Paeryn
Posts: 2146
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: smbus read_block_data() definition

Tue Sep 25, 2018 6:55 pm

picandies wrote:
Tue Sep 25, 2018 4:17 pm
The device specifies the number of returned bytes, not the user
...this is a standard rpi3 with stretch, using python
import smbus
import sys
import time
bus=smbus.SMBus(1)
get_my_data= bus.read_block_data(WHAT EXACTLY GOES IN HERE)

WHAT are these parameters , please list & describe
I need to read 10 bytes of data to be rcvd
Did you ask Python?

Code: Select all

[email protected]:~ $ python3
Python 3.5.3 (default, Jan 19 2017, 14:11:04)
[GCC 6.3.0 20170124] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import smbus
>>> help(smbus.SMBus.read_block_data)

Help on method_descriptor:

read_block_data(...)
    read_block_data(addr, cmd) -> results

    Perform SMBus Read Block Data transaction.
The first parameter is the address of the device, the second is the command (which selects which register to read from). What is returned is a list of the bytes that the device gives you. As joan told you earlier, how many bytes it returns is dependant on how many the device says it is sending. If you only want the first 10 then just use the first 10.
She who travels light — forgot something.

picandies
Posts: 122
Joined: Wed Nov 26, 2014 5:13 pm

Re: smbus read_block_data() definition

Tue Sep 25, 2018 7:44 pm

Did you ask Python?

THANK YOU !!!!!...this is great...never thought of asking the rpi...I knew you could get help on Linux commands like help echo'

By the way where is this info actually defined/described in the real world (as an actual document rather then posts/comments)

Idahowalker
Posts: 333
Joined: Wed Jan 03, 2018 5:43 pm

Re: smbus read_block_data() definition

Tue Sep 25, 2018 8:20 pm

http://ww2.cs.fsu.edu/~rosentha/linux/2 ... e1222.html
Name

i2c_smbus_read_block_data — SMBus block read request

Synopsis

s32 i2c_smbus_read_block_data ( struct i2c_client * client,
u8 command,
u8 * values);
Arguments

client
Handle to slave device

command
Command byte issued to let the slave know what data should be returned

values
Byte array into which data will be read; big enough to hold the data returned by the slave. SMBus allows at most 32 bytes.

Description

Returns the number of bytes read in the slave's response, else a negative number to indicate some kind of error.

Note that using this function requires that the client's adapter support the I2C_FUNC_SMBUS_READ_BLOCK_DATA functionality. Not all adapter drivers support this; its emulation through I2C messaging relies on a specific mechanism (I2C_M_RECV_LEN) which may not be implemented.
Being a programmer: She says go to the store get 1 bottle of milk, if they have eggs bring back 6. She gets mad cause I brought back 6 bottles of milk.

picandies
Posts: 122
Joined: Wed Nov 26, 2014 5:13 pm

Re: smbus read_block_data() definition

Tue Sep 25, 2018 9:43 pm

s32 i2c_smbus_read_block_data ( struct i2c_client * client,
u8 command,
u8 * values);
Thanks for the reply, though I'm not sure how it makes sense...This mean you'd do the following?

using the 3 parameters/arguments given, an example

gotvalues = mybus.i2c_smbus_read_block_data(20, 34, [1,2,3,4])

I'm confused about the third parameter/argument...why would you provide a list of values?

User avatar
joan
Posts: 13558
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: smbus read_block_data() definition

Tue Sep 25, 2018 10:04 pm

The example was for C/C++ and values is a return parameter. Presumably they will contain the values returned by the SMBus command.

This is all moot. What device are you trying to talk to? It is pretty unlikely it actually accepts SMBus commands. Most devices are I2C.

picandies
Posts: 122
Joined: Wed Nov 26, 2014 5:13 pm

Re: smbus read_block_data() definition

Tue Sep 25, 2018 10:54 pm

It is pretty unlikely it actually accepts SMBus commands

Its another processor I am programming, so it is whatever I program, but Iwas trying to use the mentioned function on the rpi end.

I find it strange that there doesn't seem to be any readily accessable documentation on the rpi site, or any other...the one link mentioned was from Florida State. There is the pigpio site, but am not sure if that site refers to the same function.

I did find some old info that this function does not work on the rpi, so maybe I'd better forget it. Or perhaps that was years ago & now working...hard to tell via internet searching.

Maybe the info is buried somewhere on the GCC site.

User avatar
Paeryn
Posts: 2146
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: smbus read_block_data() definition

Wed Sep 26, 2018 1:13 am

picandies wrote:
Tue Sep 25, 2018 7:44 pm
Did you ask Python?

THANK YOU !!!!!...this is great...never thought of asking the rpi...I knew you could get help on Linux commands like help echo'
Python's help() function shows you the docstring for the object you pass it so it is up to the author of a module to proved relevant text.
By the way where is this info actually defined/described in the real world (as an actual document rather then posts/comments)
Usually the 1st place I'd look is in the horse's mouth http://www.smbus.org/specs/], it doesn't give Python implementation but Python's is a wrapper around the original C.
She who travels light — forgot something.

picandies
Posts: 122
Joined: Wed Nov 26, 2014 5:13 pm

Re: smbus read_block_data() definition

Wed Sep 26, 2018 1:58 am

Thanks for your reply...its fine for now...but I still wonder for my rpi3 running stretch
Usually the 1st place I'd look is in the horse's mouth http://www.smbus.org/specs/], it doesn't give Python implementation
I originally looked around there , but no answer to my question about the command parameter format for the python commands.
I suppose some things remain a mystery!

User avatar
joan
Posts: 13558
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: smbus read_block_data() definition

Wed Sep 26, 2018 7:26 am

The pigpio documentation includes details of the transactions carried out by each SMBus command (see the note for http://abyz.me.uk/rpi/pigpio/python.html#i2c_open).

The Python smbus module (to my mind) is exceptionally poorly documented.

picandies
Posts: 122
Joined: Wed Nov 26, 2014 5:13 pm

Re: smbus read_block_data() definition

Wed Sep 26, 2018 5:25 pm

Thank you Joan!!

I wonder how the Python lib can be poorly documented...how does everyone use it? Well, I suppose that's how it is.

Return to “Python”

Who is online

Users browsing this forum: Galbi3000, MrYsLab, przemof and 16 guests