flush tty device buffer from terminal
I have a serial device on /dev/ttyAMA0
. I have program written in C that communicates with this device. But apart from the C program I sometimes need to input some configuration data from terminal, for example: echo xxx >> /dev/ttyAMA0
. Problem is that the device replies to this configuration input (something like parameter xxx set
) but I do not read (because I don't need to) this reply so it buffers in the serial port's buffer. This causes problems in the C program because I need to read data from it but there is already this reply buffered that I do not care about.
So my question. How do I flush device's buffer from terminal? I know I can use tcflush(sfd, TCIOFLUSH);
in C but I need to do it from terminal.
tty devices buffer
add a comment |
I have a serial device on /dev/ttyAMA0
. I have program written in C that communicates with this device. But apart from the C program I sometimes need to input some configuration data from terminal, for example: echo xxx >> /dev/ttyAMA0
. Problem is that the device replies to this configuration input (something like parameter xxx set
) but I do not read (because I don't need to) this reply so it buffers in the serial port's buffer. This causes problems in the C program because I need to read data from it but there is already this reply buffered that I do not care about.
So my question. How do I flush device's buffer from terminal? I know I can use tcflush(sfd, TCIOFLUSH);
in C but I need to do it from terminal.
tty devices buffer
You are asking the wrong question. The right question to ask is what tool you can use to speak with your device properly, sinceecho
clearly only does half the job.
– JdeBP
Feb 25 at 10:23
add a comment |
I have a serial device on /dev/ttyAMA0
. I have program written in C that communicates with this device. But apart from the C program I sometimes need to input some configuration data from terminal, for example: echo xxx >> /dev/ttyAMA0
. Problem is that the device replies to this configuration input (something like parameter xxx set
) but I do not read (because I don't need to) this reply so it buffers in the serial port's buffer. This causes problems in the C program because I need to read data from it but there is already this reply buffered that I do not care about.
So my question. How do I flush device's buffer from terminal? I know I can use tcflush(sfd, TCIOFLUSH);
in C but I need to do it from terminal.
tty devices buffer
I have a serial device on /dev/ttyAMA0
. I have program written in C that communicates with this device. But apart from the C program I sometimes need to input some configuration data from terminal, for example: echo xxx >> /dev/ttyAMA0
. Problem is that the device replies to this configuration input (something like parameter xxx set
) but I do not read (because I don't need to) this reply so it buffers in the serial port's buffer. This causes problems in the C program because I need to read data from it but there is already this reply buffered that I do not care about.
So my question. How do I flush device's buffer from terminal? I know I can use tcflush(sfd, TCIOFLUSH);
in C but I need to do it from terminal.
tty devices buffer
tty devices buffer
asked Feb 25 at 10:05
mulikumuliku
283
283
You are asking the wrong question. The right question to ask is what tool you can use to speak with your device properly, sinceecho
clearly only does half the job.
– JdeBP
Feb 25 at 10:23
add a comment |
You are asking the wrong question. The right question to ask is what tool you can use to speak with your device properly, sinceecho
clearly only does half the job.
– JdeBP
Feb 25 at 10:23
You are asking the wrong question. The right question to ask is what tool you can use to speak with your device properly, since
echo
clearly only does half the job.– JdeBP
Feb 25 at 10:23
You are asking the wrong question. The right question to ask is what tool you can use to speak with your device properly, since
echo
clearly only does half the job.– JdeBP
Feb 25 at 10:23
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f502824%2fflush-tty-device-buffer-from-terminal%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f502824%2fflush-tty-device-buffer-from-terminal%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You are asking the wrong question. The right question to ask is what tool you can use to speak with your device properly, since
echo
clearly only does half the job.– JdeBP
Feb 25 at 10:23