Skip to content
Snippets Groups Projects
Commit 735791f3 authored by Arnaud Blanchard's avatar Arnaud Blanchard
Browse files

Remove the test channel on the system at the end

parent 9686ae3e
No related branches found
No related tags found
No related merge requests found
...@@ -29,6 +29,8 @@ class BlcChannel: ...@@ -29,6 +29,8 @@ class BlcChannel:
lib.blc_channel_wait_ack_data.argtypes = [ c_void_p ] lib.blc_channel_wait_ack_data.argtypes = [ c_void_p ]
lib.blc_channel_post_new_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_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} 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: ...@@ -118,8 +120,12 @@ class BlcChannel:
def post_ack_data(self): def post_ack_data(self):
BlcChannel.lib.blc_channel_post_ack_data(self.channel) BlcChannel.lib.blc_channel_post_ack_data(self.channel)
def remove(self):
BlcChannel.lib.blc_channel_remove(self.channel)
def __del__(self): 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 @property
def list(self): def list(self):
...@@ -128,9 +134,17 @@ class BlcChannel: ...@@ -128,9 +134,17 @@ class BlcChannel:
return data_list return data_list
if __name__ == "__main__": 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 = 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) 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("type",channel_read.type, "format", channel_read.format, "length", channel_read.total_length)
print(channel_read.array[:channel.total_length]) print(channel_read.array[:channel.total_length])
print("We remove our shared memory from the system")
channel.remove()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment