Hello all,
I am trying to debug the communication to the DS2450.
I found a problem of my communication within the "OW_set_resolution"
function in the ow_DS2450.c Module.
I add "printf" functions to see where the program does something.
Here the modified function:
static GOOD_OR_BAD OW_set_resolution( int resolution, struct parsedname
* pn )
{
int stored_resolution ;
/* Resolution */
if ( BAD( Cache_Get_SlaveSpecific(_resolution,
sizeof(stored_resolution), SlaveSpecificTag(RES), pn))
|| stored_resolution != resolution) {
// need to set resolution
BYTE p[_1W_2450_PAGESIZE];
RETURN_BAD_IF_BAD( OW_r_mem(p, _1W_2450_PAGESIZE,
_ADDRESS_CONTROL_PAGE, pn) ) ;
p[_1W_2450_REG_A] &= ~_1W_2450_RC_MASK ;
p[_1W_2450_REG_A] |= ( resolution & _1W_2450_RC_MASK ) ;
p[_1W_2450_REG_B] &= ~_1W_2450_RC_MASK ;
p[_1W_2450_REG_B] |= ( resolution & _1W_2450_RC_MASK ) ;
p[_1W_2450_REG_C] &= ~_1W_2450_RC_MASK ;
p[_1W_2450_REG_C] |= ( resolution & _1W_2450_RC_MASK ) ;
p[_1W_2450_REG_D] &= ~_1W_2450_RC_MASK ;
p[_1W_2450_REG_D] |= ( resolution & _1W_2450_RC_MASK ) ;
printf("2450 OW_set_resolution OW_r_mem o.k. \n") ;
RETURN_BAD_IF_BAD( OW_w_mem(p, _1W_2450_PAGESIZE,
_ADDRESS_CONTROL_PAGE, pn) );
printf("2450 OW_set_resolution OW_w_mem o.k. \n") ;
return Cache_Add_SlaveSpecific(, sizeof(int),
SlaveSpecificTag(RES), pn);
}
return gbGOOD ;
}
I also add debug code in the OW_w_mem() function to see the problem.
Here the function :
//write bytes[size] is now common for normal and eeprom
static GOOD_OR_BAD OW_w_mem(BYTE * data, size_t size, off_t offset,
struct parsedname * pn)
{
size_t remain = size ;
off_t local_offset = 0 ;
int retry=0; //retry at 32byte block level because it is sometime hard
to have a scuccession of 16 successfull bloc writes
printf("OW_w_mem entered \n") ;
while ( remain > 0 )
{
size_t gulp = remain ;
if ( gulp > _FC02_MAX_READ_GULP ) {
gulp = _FC02_MAX_READ_GULP ;
}
// RETURN_BAD_IF_BAD( OW_w_mem_small( [local_offset], gulp,
offset+local_offset, pn ));
if ( BAD( OW_w_mem_small( [local_offset], gulp,
offset+local_offset, pn )))
{
printf("Bad 2450 OW_w_mem Remain : %i Gulp : %i\n",remain,
gulp) ;
if (retry++>3) return gbBAD;
UT_delay(2) ; //give 1.5 msec to finish prev write
before retrying
(specificly for eeprom write)
}
else
{
printf("Good 2450 OW_w_mem Remain : %i Gulp : %i\n",remain,
gulp) ;
remain -= gulp ;
local_offset += gulp ;
retry=0;
}
}
return gbGOOD ;
}
But I do not get the print out "OW_w_mem entered" and I do not know why.
The only print out I get is "2450 OW_set_resolution OW_r_mem o.k."
Where is my failure ?
Best regards
Ritchie
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Owfs-developers mailing list
Owfs-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/owfs-developers