tarm / serial

BSD 3-Clause "New" or "Revised" License
1.6k stars 453 forks source link

Add use offset and length to copy read data. #77

Closed MiyamuraMiyako closed 6 years ago

MiyamuraMiyako commented 6 years ago

add Read2 function to each platform.

tarm commented 6 years ago

Can you elaborate on why this should be part of the package?

If the caller wants to discard the first few bytes, then the caller can do that. Add this point I don't understand why this should be part of the package.

MiyamuraMiyako commented 6 years ago

Not to discard the header data, this function is read multiple and sequentially into the slice.

MiyamuraMiyako commented 6 years ago

example: image

I want this function because of the pcomm library in windows: PCOMM.H Line105

May be my solution not perfect.

xiegeo commented 6 years ago

If I understand the problem correctly, instead of doing Read2(buf, start, length), you can do Read(buf[start:start+length])

MiyamuraMiyako commented 6 years ago

Oh, you are right. It seems this pr can be closed