diff --git a/python/blc_channel.py b/python/blc_channel.py index d2dc341026818a4286f18e47a566d86ad214f9db..8b11fc384798e73042e426b37af0ee74d95e21dd 100644 --- a/python/blc_channel.py +++ b/python/blc_channel.py @@ -29,6 +29,8 @@ class BlcChannel: lib.blc_channel_wait_ack_data.argtypes = [ c_void_p ] lib.blc_channel_post_new_data.argtypes = [ c_void_p ] lib.blc_channel_post_ack_data.argtypes = [ c_void_p ] + lib.blc_channel_remove.argtypes = [ c_void_p ] + types={ 'UIN8': c_uint8, 'INT8': c_int8, 'UI16': c_uint16, 'INT16': c_int16, 'UI32': c_uint32, 'IN32': c_int32, 'UI64': c_uint64, 'IN64': c_int64, 'FL32': c_float, 'FL64': c_double} @@ -118,8 +120,12 @@ class BlcChannel: def post_ack_data(self): BlcChannel.lib.blc_channel_post_ack_data(self.channel) + def remove(self): + BlcChannel.lib.blc_channel_remove(self.channel) + def __del__(self): - BlcChannel.lib.blc_channel_delete(self.channel) + BlcChannel.lib.blc_channel_delete(self.channel) #Fre the local object but do not destroy the system shared memory + @property def list(self): @@ -128,9 +134,17 @@ class BlcChannel: return data_list if __name__ == "__main__": - # EXEMPLE + print() + print("EXEMPLE: blc_channel") + print("We create a blc_channel of type unsigned char and size 3x2 on the POSIX system (shared memory)") channel = BlcChannel("/python_test", os.O_RDWR, 'UIN8', 'RGB3', [3, 2]) - #channel.wait_new_data() #This needs data to be named .data + print("We write 7 in column 2") + channel.array[2]=7 + print("We open the shared blc_channel to read it") channel_read = BlcChannel("/python_test", os.O_RDONLY) + print("We check that we have the same values") print("type",channel_read.type, "format", channel_read.format, "length", channel_read.total_length) print(channel_read.array[:channel.total_length]) + print("We remove our shared memory from the system") + channel.remove() +