On 11/04/2015 02:02 PM, Jan Kandziora wrote: > Am 04.11.2015 um 12:32 schrieb Martin Patzak (GMX): >> while further investigating the problem it looks like this: >> >> the value of sensed.BYTE toggles between *55* (00110111) and *183* >> (10110111) for quite a while - so its only flipping one bit. >> >> When I increase the toggling speed, I can provoke my *553* error from >> *sensed.BYTE* from once a day to several times a minute. >> >> It looks like reading the owfs-file *sensed.BYTE* in python 2.7 is not >> an atomic function!?! >> >> Any thoughts? >> > That doesn't mean the function is non-atomic but it means a > copy-to-buffer operation is broken, as it doesn't add the required \0 to > the "55" string. > > Which python binding to you use? Do you > > import ow > > or > > import ownet > > ? > > Kind regards > > Jan >
Jan, thanks for the quick reply. I do not import ow or ownet, but read the file directly in the file-system mounted by owfs I started out years ago with perl and then transferred part to python. I never got around using ow or ownet. Can I read the \0 with a python .read() command? The code looks like --------- begin code ------------- def RD_IO_byte(st, path, id, error): ## this function reads sensed.BYTE and returns the bits as list of INT starting with MSB ## if there is a problem it returns None and error[0] will be non-zero # path - full path to owfs # id - ID of 1-wire device # bits - a integer list of all 8 bits from 0 to 7, the whole byte id = os.path.join(path, id) error[0] = -99 try: byte = open(id +'/sensed.BYTE', 'r') # open our fuse-file except: print text_de.name[st], 'Could not open ', id, '/sensed.BYTE for reading!' return None else: str_byte = byte.read() # read the integer value of BYTE as string byte.close() # close the fuse-file value = int(str_byte) # once in a while it crashes here, so we need to find out why if (value < 0) or (value > 255): print text_de.name[st], 'Got int-value ', value, ' from string ',str_byte,' reading ', id, '/sensed.BYTE ' bits = int2bin(int(str_byte)) # make a bit-list out of the integer bits = invert_byte(bits) # error[0] = 0 #print 'error in RD_IO_byte', error[0] return bits ----- end code ------ Martin > > ------------------------------------------------------------------------------ > _______________________________________________ > Owfs-developers mailing list > Owfs-developers@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/owfs-developers > ------------------------------------------------------------------------------ _______________________________________________ Owfs-developers mailing list Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers