G'Day, > > As to the specifics of the function called when catting > > 2D.serial/memory/, perhaps it is just my misunderstanding, but it > > seems to me like calling BUS_send_data() is not the best thing to > > do. BUS_send_data(x,3,y) sends three bits, then reads three bits and > > compares them. If I am correctly understanding the way this device > > works, are the bits you read back there not the contents of the > > memory? I could very well be wrong here, as I am finding the > > documentation for the device a little hard to follow at times, but > > that is just how it seems to me: I need to send 0xF0, some sort of > > reference address, then start reading back data stored in that > > address. > > > Never properly documented, but: > BUS_send_data sends and compares data (the "data" is specific to > DS2480B/DS9097U syntax that uses in-band commands to the adapter, > hence "data" and "command" modes). > BUS_sendback_data sends data and returns what it reads. > BUS_readin_data sends dummy data and returns what it reads. > > Clearly these are all slight variations of the underlying "send bits > and look at what the bus does to them", but that's the essence of > 1-wire communication.
I understand that BUS_sendback_/readin_data() relate to the protocol used by those adaptors then? They may not be completely compatible with the OMAP boards, so I may need to add an option which skips aspects if it is using the OMAP hardware support. > Tell me specifically where you are looking, please. I have been using the Dallas documentation for the DS2431 as my reference on how things work on the device: http://www.maxim-ic.com/getds.cfm?qv_pk=4272&ln=en > > I have been watching what happens when I cat `memory' with an > > oscilloscope, and noted some rather unusual behaviour. For some reason, > > when I cat this file the `Match ROM' command (effectively, BUS_select() > > for the purposes of owfs), is being performed twice, then nothing else. > > The OW_r_mem() function in ow_2433.c, however, lists a BUS_select() call > > followed by BUS_send_data() and BUS_readin_data(), so I am not sure why > > nothing is getting called after BUS_select(), nor why that function is > > being called twice. > > > Sounds like a problem with the select. > The routine is as follows: > > static int OW_r_mem( unsigned char * data , const size_t size , const size_t > offset, const struct parsedname * pn) { > unsigned char p[] = { 0xF0, offset&0xFF, offset>>8, } ; > int ret ; > //printf("reading offset=%d size=%d bytes\n", offset, size); > > BUSLOCK(pn); > ret = BUS_select(pn) || BUS_send_data( p, 3,pn ) || > BUS_readin_data( data,size,pn ); > BUSUNLOCK(pn); > if ( ret ) return 1; > > return 0 ; > } I am still not sure why it is doing the double BUS_select() (perhaps it is from another function called shortly before this?), but I have identified the problems. Firstly, there was an excess return still hanging in OMAP_select() (I thought I had already removed all of them, but obviously not): this is why it was never calling BUS_send_data(). As for BUS_send_data(), on the OMAP it writes the three bits in p, then reads back three bits --- which are the first three bits of memory --- and compares them. If they ever match up, it will be an amazing coincidence. I have tested it with the following: ret = BUS_select(pn) || write(pn->in->fd, p, 3) || read(pn->in->fd, data, size); With those changes I am now able to read from memory. I have also tried reading from pages/page.X (they use the same function, so they should work): they *seem* to `work' (there are no errors, and the oscilloscope shows the values coming in), but I receive an empty set with them, while memory returns a lot of 0xFFs. Perhaps that is intentional though? I tried writing to memory, however OW_write_paged() exits early --- I have not yet identified why. I am also trying to write to pages/page.X, however, they fail right at the start of the code: if ( start || (size&0x07) || OW_r_mem( &p[3], 8, offset-start, pn ) ) return 1 ; The value of start (and size&0x07 for that matter) is true, therefore the function never gets a chance. The comment above the line (this is in ow_2433.c::OW_w_mem2D() by the way) reads as if it should be something more like this: if (start && (size&07)) if (OW_r_mem(&p[3], 8, offset-start, pn)) return 1; Am I understanding that correctly? If not, is there something else wrong with that line? It seems to me that it is impossible to write to the device, given it fails without even getting started. -- Matthew ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click _______________________________________________ Owfs-developers mailing list Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers