@@ -295,12 +295,34 @@ public static int plc_tag_get_string_total_length(Int32 tag_id, int string_start
295295
296296 public static int plc_tag_get_raw_bytes ( Int32 tag_id , int start_offset , byte [ ] buffer , int buffer_length )
297297 {
298- return NativeMethods . plc_tag_get_raw_bytes ( tag_id , start_offset , buffer , buffer_length ) ;
298+ return plc_tag_get_raw_bytes ( tag_id , start_offset , buffer . AsSpan ( 0 , buffer_length ) ) ;
299+ }
300+
301+ public static int plc_tag_get_raw_bytes ( Int32 tag_id , int start_offset , Span < byte > buffer )
302+ {
303+ unsafe
304+ {
305+ fixed ( byte * ptr = buffer )
306+ {
307+ return NativeMethods . plc_tag_get_raw_bytes ( tag_id , start_offset , ptr , buffer . Length ) ;
308+ }
309+ }
299310 }
300311
301312 public static int plc_tag_set_raw_bytes ( Int32 tag_id , int start_offset , byte [ ] buffer , int buffer_length )
302313 {
303- return NativeMethods . plc_tag_set_raw_bytes ( tag_id , start_offset , buffer , buffer_length ) ;
314+ return plc_tag_set_raw_bytes ( tag_id , start_offset , new ReadOnlySpan < byte > ( buffer , 0 , buffer_length ) ) ;
315+ }
316+
317+ public static int plc_tag_set_raw_bytes ( Int32 tag_id , int start_offset , ReadOnlySpan < byte > buffer )
318+ {
319+ unsafe
320+ {
321+ fixed ( byte * ptr = buffer )
322+ {
323+ return NativeMethods . plc_tag_set_raw_bytes ( tag_id , start_offset , ptr , buffer . Length ) ;
324+ }
325+ }
304326 }
305327
306328
0 commit comments