lancaster-university / codal-core

MIT License
10 stars 28 forks source link

Serial readUntil locks if delimiter is not found and rx is full #80

Open pelikhan opened 5 years ago

pelikhan commented 5 years ago

https://github.com/lancaster-university/codal-core/blob/4aab0974f176dd92c5551efab8d368e3c79079b1/source/driver-models/Serial.cpp#L55

If a fiber is waiting of readUntil and the RX is full, it never receives triggers and the serial is effectively locked.

pelikhan commented 5 years ago

@finneyj @jamesadevine not sure how to handle this case. What happens when RX gets full and a fiber is waiting on some delimiters?

jamesadevine commented 5 years ago

I think this is for the user to decide, I.e. wait forever or timeout

waitUntil(delimiters, timeout);

Default of 0?

pelikhan commented 5 years ago

Right now we have “readUntil” that waits forever.

Get Outlook for iOShttps://aka.ms/o0ukef


From: James Devine notifications@github.com Sent: Tuesday, January 1, 2019 9:31 AM To: lancaster-university/codal-core Cc: Peli de Halleux; Author Subject: Re: [lancaster-university/codal-core] Serial readUntil locks if delimiter is not found and rx is full (#80)

I think this is for the user to decide, I.e. wait forever or timeout

waitUntil(delimiters, timeout);

Default of 0?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Flancaster-university%2Fcodal-core%2Fissues%2F80%23issuecomment-450745108&data=02%7C01%7Cjhalleux%40microsoft.com%7Ccfeba1055fc748cc2cfe08d6700ef587%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636819606879798883&sdata=i3X3OS5o7XgOC%2FDPekclIGfr%2Bn3Vq5ov9ogz8ZrbIJI%3D&reserved=0, or mute the threadhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAD-4KVAM57muRvhgkbU-36TG7Irkc2XUks5u-5tugaJpZM4Zl9u1&data=02%7C01%7Cjhalleux%40microsoft.com%7Ccfeba1055fc748cc2cfe08d6700ef587%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636819606879798883&sdata=LDGLI3fSSoixJeXol8O1PkVgI85WhrkHvrY6mqfFZHA%3D&reserved=0.

jamesadevine commented 5 years ago

Sorry meant readUntil (mac is in the shop so I’m on my phone)

James.

On 1 Jan 2019, at 18:01, Peli de Halleux notifications@github.com<mailto:notifications@github.com> wrote:

Right now we have “readUntil” that waits forever.

Get Outlook for iOShttps://aka.ms/o0ukef


From: James Devine notifications@github.com<mailto:notifications@github.com> Sent: Tuesday, January 1, 2019 9:31 AM To: lancaster-university/codal-core Cc: Peli de Halleux; Author Subject: Re: [lancaster-university/codal-core] Serial readUntil locks if delimiter is not found and rx is full (#80)

I think this is for the user to decide, I.e. wait forever or timeout

waitUntil(delimiters, timeout);

Default of 0?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Flancaster-university%2Fcodal-core%2Fissues%2F80%23issuecomment-450745108&data=02%7C01%7Cjhalleux%40microsoft.com%7Ccfeba1055fc748cc2cfe08d6700ef587%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636819606879798883&sdata=i3X3OS5o7XgOC%2FDPekclIGfr%2Bn3Vq5ov9ogz8ZrbIJI%3D&reserved=0, or mute the threadhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAD-4KVAM57muRvhgkbU-36TG7Irkc2XUks5u-5tugaJpZM4Zl9u1&data=02%7C01%7Cjhalleux%40microsoft.com%7Ccfeba1055fc748cc2cfe08d6700ef587%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636819606879798883&sdata=LDGLI3fSSoixJeXol8O1PkVgI85WhrkHvrY6mqfFZHA%3D&reserved=0.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/lancaster-university/codal-core/issues/80#issuecomment-450746886, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AEheKQHtYuDQ-zgoTpKBGJh53OS-j7EUks5u-6KGgaJpZM4Zl9u1.

pelikhan commented 5 years ago

Since MakeCode moved to UF8 support, I ended not using this implementation in MakeCode at all.

jamesadevine commented 5 years ago

How does that work with serial now then?

pelikhan commented 5 years ago

Just doing the same logic on the TS side.

https://github.com/Microsoft/pxt-common-packages/blob/master/libs/serial/serial.ts#L53

jamesadevine commented 5 years ago

Same problem exists if you do a blocking read on read(), right? i.e. you will wait for a character forever...

jamesadevine commented 5 years ago

If you're going to implement this in ts, pass ASYNC and sleep in the loop.

pelikhan commented 5 years ago

ok will do. I am trying the new serial on SAMD21, which board did you test it on?

jamesadevine commented 5 years ago

Currently 0 boards, my SAMD's are at the office. It should work fine, I was going to test on CPX on A2.