Skip to content

Commit

Permalink
serial: Add manual test for control flow behavior
Browse files Browse the repository at this point in the history
This test uses a device configured for loopback (with RTS and CTS) lines
connected to validate that the RTS pin can be configured manually or
automatically depending on the flow control configuration.

Bug: 1287309
Change-Id: Id260d41fcb714529bf3e3754608db6485d2901e2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3390190
Auto-Submit: Reilly Grant <[email protected]>
Reviewed-by: Matt Reynolds <[email protected]>
Commit-Queue: Matt Reynolds <[email protected]>
Cr-Commit-Position: refs/heads/main@{#961185}
  • Loading branch information
reillyeon authored and chromium-wpt-export-bot committed Jan 20, 2022
1 parent 466383c commit ee6da9d
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions serial/serialPort_loopback_flowControl-manual.https.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/common.js"></script>
<script src="resources/manual.js"></script>
</head>
<body>
<p>
These tests require a connected serial device configured to act as a
"loopback" device, with the TX and RX pins and RTS and CTS pins wired
together.
</p>
<script>
manual_serial_test(async (t, port) => {
await port.open({
baudRate: 115200,
bufferSize: 255,
flowControl: 'none'
});
t.add_cleanup(async () => {
await port.close();
});

await port.setSignals({ requestToSend: true });
let signals = await port.getSignals();
assert_true(signals.clearToSend);

await port.setSignals({ requestToSend: false });
signals = await port.getSignals();
assert_false(signals.clearToSend);
}, 'Manual RTS control works with no flow control enabled');

manual_serial_test(async (t, port) => {
await port.open({
baudRate: 115200,
bufferSize: 255,
flowControl: 'hardware'
});

const writer = port.writable.getWriter();
t.add_cleanup(async () => {
writer.releaseLock();
await port.close();
});

assert_true((await port.getSignals()).clearToSend);

const buffer = new Uint8Array(1);
while ((await port.getSignals()).clearToSend) {
await writer.write(buffer);
}
}, 'Hardware flow control automatically sets RTS pin');
</script>
</body>
</html>

0 comments on commit ee6da9d

Please sign in to comment.