From: Alessio Sangalli <alesan-+h0hele9I7BBDgjK7y7TUQ@public.gmane.org>
To: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Correct i2c access semantics
Date: Wed, 13 May 2015 16:01:51 -0700 [thread overview]
Message-ID: <5553D7DF.4090504@manoweb.com> (raw)
Hello. I am writing a small program to read "DDC" data from a monitor on
the i2c bus. My application is custom so I need to properly init and
program an FPGA before I can access the monitor.
What I am seeing is that if I open() the correct i2c bus, then I ioctl
with I2C_SLAVE to select the right slave, then read(fd, buffer, 0x100) I
can consistently access the correct data.
However, if I only read(fd, buffer, 0x80) (in fact I do not need the
DDC/EDID data above 0x80 for my application), next time I run the
program, it will start reading from offset 0x80 from that device. In
fact, it seems like there is a static index on the i2c reads, that is
not reset when I perform close(), open(), or the program exits.
However, if I do one i2c_smbus_read_byte_data() it will always reset the
offset read to the first byte.
i2c_smbus_read_byte_data(fd, 0);
i = read(fd, data + 1, 0xff);
The code above ALWAYS read the same bytes from the i2c device.
Is this the expected behaviour, or am I missing something? I am using an
older Linux 3.5 in this application.
Thank you
as
reply other threads:[~2015-05-13 23:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5553D7DF.4090504@manoweb.com \
--to=alesan-+h0hele9i7bbdgjk7y7tuq@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).