For the I2C-1 "file", is it possible to set/send the port address seperatily ?

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hello All,

When I open /dev/i2c-1 and want to send some data to a certain port on the  
target device I currently always need to first combine the two into a single  
buffer, and than call 'write' providing it that buffer.  Which feels a bit  
wastefull to me.

My question therefore is:
1) Is there a way, for the above I2C "file", to do a multi-part write which  
gets accepted as a single one ?
- and/or -
2) Is there a way to set the target port in another way - maybe in the same  
way the device address is currently set (using ioctl) ?

My googeling did not turn up anything like it, which I why I'm asking here.

Regards,
Rudy Wieser



Re: For the I2C-1 "file", is it possible to set/send the port address seperatily ?
On Fri, 22 Dec 2017 11:28:07 +0100

Quoted text here. Click to load it

To do that it would have to write into a buffer, then send it ...


Re: For the I2C-1 "file", is it possible to set/send the port address seperatily ?
Rob,

Quoted text here. Click to load it

The question is, why do you have to ?   I mean, I can write a line to the  
console in multiple parts by simply not sending an EOL.  No kind of buffer  
involved ...

Regards,
Rudy Wieser



Re: For the I2C-1 "file", is it possible to set/send the port address seperatily ?
R.Wieser wrote:

Quoted text here. Click to load it

For many i2C devices you write a register address, followed by the value  
to be written to that register, and possibly data to be written to  
successive registers, these need to be atomic.

Quoted text here. Click to load it
What happens if process A writes "hello" to the console one character at  
a time, while process B writes "goodbye" to the console, also one  
character at a time?

What if process A writes "1" followed by "2" to the I2C port and process  
B writes "3" followed by "4" to the I2C port?

Do you get 2 written to register 1, and 4 written to register 3?
or 3 written to register 1 and 4 written to register 2?
or 1 written to register 3 and 2 written to register 4?
or ...

Your I2C controlled hardware is going to behave unexpectedly


Re: For the I2C-1 "file", is it possible to set/send the port address seperatily ?
Andy,

Quoted text here. Click to load it

I'm aware of that.   However, the need for it to be atomic has no bearing on  
the speed of the transmission, or including the possibility of (long) pauses  
between clockpulses (between, or even inside a byte) (regardless of whom or  
what is introducing them).

Quoted text here. Click to load it

Thats the problem with providing examples.  Some people tend to focus on it,  
and forget to check if the response/counter example they give is actually  
applicable to the problem it tried to clarify. :-(

I the case of a console you would (often) just get a spagetti of  
letters/words.

However, when such a mash is not considered to be anything of a good idea -  
like with I2C and a slew of other devices - process B gets simply told to  
wait (gets forced into a wait state) until process A indicates its finished.

... which is what currently already happens when process A is busy with a  
length write and proces B also wants to say something.

Regards,
Rudy Wieser



Re: For the I2C-1 "file", is it possible to set/send the port address seperatily ?
Quoted text here. Click to load it

You might try writev(2) - this is not an I2C function, but a standard
unix function to do a single write from multiple buffers which are
gathered into a single syscall, and passed as an array of pointers
and lengths. I haven't actually tried it with Linux I2C driver though.

Quoted text here. Click to load it

A target port is something related to your I2C device and not I2C itself,
and you didn't say what that was, so no one is going to be able to answer.

Quoted text here. Click to load it

--  
Andrew Gabriel
[email address is not usable -- followup in the newsgroup]

Re: For the I2C-1 "file", is it possible to set/send the port address seperatily ?
Andrew,

Quoted text here. Click to load it

Thank you.  Its a good starting point to do some googeling and testing.

Quoted text here. Click to load it

Just regard it as a second address byte - which is actually a thing -  
indicating one outof 65536 devices.  Hmmm ... Is there a possibility to set  
a two-byte device adddress ?

Quoted text here. Click to load it

My question was aimed at I2C (or rather, the API talking to it), not a(ny)  
specific slave device using it.  That I mentioned the target port was just  
ment as an example, something to relate to.

In my case the device I'm working with does not use a "target port", just a  
single bit in the first "databyte" to indicate a read or write action -  
which is rather indistinguishable from a "target port" though. :-)

Though if you need to think of one you can pick any which accepts a(ny)  
number of databytes preceeded by a single target port byte.  Any I2C EPROM,  
I2C to RS232 or SPI convertor, I2C display, bluetooth, etc. will do.

Regards,
Rudy Wieser  



Re: For the I2C-1 "file", is it possible to set/send the port address seperatily ?
Andrew,

Quoted text here. Click to load it

I just did so (with the help of an online man page).  Alas, although the  
result is different from doing two seperate "write"s, its not the same to  
what its expected to do (and my origional code does).

Which is surprising, as the command seems to do pretty-much the same as my  
origional code (using a temporary buffer, although that one is most likely  
dynamic, not fixed).

It seems to work for screen output though.

Regards,
Rudy Wieser



Re: For the I2C-1 "file", is it possible to set/send the port address seperatily ? writev update
Andrew,

An update to the proposed "writev" method.

I just attached an oscilloscope to the I2C bus, to see what actually happens  
when I use it to try to send two blocks of data as a single I2C one.

Alas, the 'scope shows the two provided blocks to be going over the I2C bus  
seperate, starting and ending both. :-\

Oh well, it was a good attempt. :-)

Regards,
Rudy Wieser



Re: For the I2C-1 "file", is it possible to set/send the port address seperatily ? writev update
Quoted text here. Click to load it

That would be a bug in the driver, but I'm not surprised.

--  
Andrew Gabriel
[email address is not usable -- followup in the newsgroup]

Re: For the I2C-1 "file", is it possible to set/send the port address seperatily ? writev update
Andrew,

Quoted text here. Click to load it

Possibly.  I think I wil try to find its sourcecode, and see what I can  
glean from it.   Than again, its possible that its defined that way (for  
some reason I currently can't think of).

Quoted text here. Click to load it

How so ?  (I would not mind getting some background info)

Regards,
Rudy Wieser



Re: For the I2C-1 "file", is it possible to set/send the port address seperatily ? writev update
Andrew,

Quoted text here. Click to load it

I found *some* sourcecode (not quite sure if it is (still) applicable),

https://raw.githubusercontent.com/raspberrypi/linux/rpi-4.9.y/drivers/i2c/i2c-dev.c

and found it doesn't implement the "writev" method.   Which, AFAICT, means  
that some layer above it does a "best effort", and does a few "write"s in a  
loop.  Hence the result I got.

Too bad, it means that I will need to keep using that "gather in a buffer  
first" method. :-(

Regards,
Rudy Wieser



Re: For the I2C-1 "file", is it possible to set/send the port address seperatily ?
On Sun, 24 Dec 2017 10:26:49 +0100, R.Wieser wrote:

Quoted text here. Click to load it

here is a silly idea
why don't you identify the "Target device" so that someone can provide  
you with an example of how to access that specific item
you will find you resolve your problem much faster if you provide all  
information.



--  
Four fifths of the perjury in the world is expended on tombstones, women
and competitors.
We've slightly trimmed the long signature. Click to see the full one.
Re: For the I2C-1 "file", is it possible to set/send the port address seperatily ?
Alister,

Quoted text here. Click to load it

"Those who do not learn from the past are doomed to make the same mistakes  
in the present and future"

I've tried what you suggested there.  Over the years quite a number of  
times.  And than mostly the replies focus on the example instead of on the  
problem, meaning that in  the end I've (again-and-again) been told not to  
want to do anything of the kind with that device, and not getting any answer  
even near to touching my actual question.

Also, the fact that you think you need to know the device means you are  
probably oblivious to where my/the problem is located (hint, its not  
anywhere near the device).

Quoted text here. Click to load it

Experience tells me otherwise.


But, I'm accepting your challenge (for no othe reason than to enable you to  
see the erring of your assumption):

My device is an SSD1306 128 x 64 bit I2C OLED display.  I need be able to  
write a few bytes (representing a bit pattern of a single 6x8  
character/symbol), but also a "refresh" a single-or-few 128-byte "line(s)"  
(outof 8), or the whole display if need be.  I would also like to be able to  
write a repeatable, multibyte pattern over part of, or the whole of the  
display.

Lets see if that info enables you to actually answer my question.   I don't  
think it will.   The only question to me is if you will fess up to it.

Just so you know: *any* answer which is specific to that device and cannot  
be used in a generic way means you automatically loose.

Yes, I'm quite the brutal asshole when challenged.  So sue me. :-)

Regards,
Rudy Wieser



Re: For the I2C-1 "file", is it possible to set/send the port address seperatily ?
On Sun, 24 Dec 2017 13:45:40 +0100, R.Wieser wrote:
Quoted text here. Click to load it

Correct I am oblivious to your problem because your question is  
confusing, tell me the device you want to talk to & I may be able to tell  
you how to talk to it  
Quoted text here. Click to load it

This suggest that you are not very good at asking questions  
Quoted text here. Click to load it
The data sheet seems prety clear. I suspect you need to use memory  
addressing mode

Quoted text here. Click to load it
then this is an impossible challenge as any solution has to be specific  
to this family of devices  

Quoted text here. Click to load it

only when challenged?

Quoted text here. Click to load it





--  
Home on the Range was originally written in beef-flat.

Re: For the I2C-1 "file", is it possible to set/send the port address seperatily ?
Alister,

Quoted text here. Click to load it

Than start with asking clarification about the part(s) you find confusing.  
There is no shame in that (other than in the eyes of people who are  
assholes - and who probably do not even know what to say/ask/think  
themselves).  Heck, its the reason this newsgroup exists.

So, what do you need clarification for ?    But mind you, just as you expect  
a good question from me, I expect a good question from you.

Quoted text here. Click to load it

Whut ?    You mean to say that you did not actually *read* my message before  
replying to it ?  Its in there, on the line starting with "My device is an".

Fuck, its even, in your reply, just about ten lines down from where you  
wrote the above ...

Quoted text here. Click to load it

And you have just proved - beyond a shadow of a doubt - that you simply  
cannot read a simple message, and than are pushing *your* inability to do so  
upon the other (me).  :-D

Also, you're unwilling to ask for clarification for stuff you do not really  
understand, but will not be stopped by such a "triviality".

Kiddo, *you* are the experience I talked about.   :-(

Quoted text here. Click to load it

Thats for you to find out.   Try it.  Just answer honestly (within the  
limits of your knowledge)  and I will probably (experience talking here  
:-) ) thank you for whatever you have to offer.

Regards,
Rudy Wieser



Re: For the I2C-1 "file", is it possible to set/send the port address seperatily ?
On Tue, 26 Dec 2017 11:52:06 +0100, R.Wieser wrote:

Quoted text here. Click to load it

you are the person who is asking for assistance assistance not me, I am  
probably not the best person to provide that answer but was at least  
trying to steer you in the right direction for someone else to help  
Quoted text here. Click to load it
no in the post I replied to there was no mention of the device
you have since provided that info and a read of the data sheet suggests  
you need to send a string of bytes to the correct device address, those  
bytes appear to be register/data pairs  
Quoted text here. Click to load it
no it is the reply to my suggestion that you identified the device
you cant even keep your trolling straight

Quoted text here. Click to load it
you have just proved you cannot even maintain a basic time frame

Quoted text here. Click to load it
I already know
I was going to look at this as a mental challenge during the quiet  
Christmas week but now know it would be a waste of time

Quoted text here. Click to load it





--  
In the Beginning there was nothing, which exploded.
(Lords and Ladies)

Re: For the I2C-1 "file", is it possible to set/send the port address seperatily ?
Alister,

Quoted text here. Click to load it

And you are the person who thought he should reply.   As such we *both* have  
our responsibilities.

Quoted text here. Click to load it

No, you didn't .  You mentioned a "silly idea" - which felt as you mocking  
me - urging me to provide specific information which, as I now may  
understand, you had *zero* idea about if it would be helpfull to the  
question in case, and in a direction which indicated you didn't even  
understand the problem to begin with.

So, I called you out and offered you my challenge.

Quoted text here. Click to load it

The post which you replied to with "tell me the device you want to talk to"  
(as quoted) certainly already contained the answer to that question.

Quoted text here. Click to load it

I could already communicate whith the device before I posted my question.  
Its not *that* hard.

The question was about *how to minimize transient memory usage*.  Nothing  
more, nothing less.

Quoted text here. Click to load it

Yeah, sure.  See above.

Quoted text here. Click to load it

:-)  I already mentioned that my challenge to you was to try to get you to  
see where you erred.  That you now consider it to be "a waste of time" is,  
as far as I can tell, you keeping your eyes shut and your ears covered while  
yelling "la la la" -- a juviniles way of expressing that they refuse to  
listen to anything thats being brought forward.


Lets face it kid, you asked for and I gave to you the device I am working  
with in my first reply to you, and I still have to see your first reference,  
let alone anything specific in regard to using that device.

You mentioned trolling ?   You could well be one yourself.   Telling people  
you can probably help hem if they give you more information, but than not  
even *trying* to actually do so.

Regards,
Rudy Wieser  



Re: For the I2C-1 "file", is it possible to set/send the port address seperatily ?
On Wed, 27 Dec 2017 09:29:29 +0100, R.Wieser wrote:

Quoted text here. Click to load it
that was an explanation as to why we wanted it & later in my reply I made  
the statement the data sheet seemed fairly straight forward, which would  
indicate not only had i seen the device but even taken the time to look  
it up
  
Quoted text here. Click to load it

i tried to move things forward by geting you to provide the group with  
full information (i believe I even said WE not I may be able to help)  
Quoted text here. Click to load it

you have a history of asking incomplete questions & then requiring more &  
more information untill it becomes apparent that you did not understand  
the basics which your original question implied, at which point it is the  
fault of this newsgroup because we did not give fUll instructions.


  





--  
Why you say you no bunny rabbit when you have little powder-puff tail?  
        -- The Tasmanian Devil

Re: For the I2C-1 "file", is it possible to set/send the port address seperatily ?
On Wed, 27 Dec 2017 12:56:09 +0000, alister wrote:

Quoted text here. Click to load it

And by the way you have not even told us what language you are  
programming in, no doubt you would get on your high horse about being  
presented with a solution in scratch although for all we know you could  
be using fortran or even assembler




--  
    After Snow White used a couple rolls of film taking pictures of  
the
We've slightly trimmed the long signature. Click to see the full one.

Site Timeline