Proper (working) way to return an int pointer through STREAMS?Possible missing firmwareIs there a way to...
Necessity of tenure for lifetime academic research
What checks exist against overuse of presidential pardons in the USA?
Can copper pour be used as an alternative to large traces?
How to animate a function plot
Is this homebrew "Faerie Fire Grenade" unbalanced?
Is "prohibition against," a double negative?
What's the difference between a variable and a memory location?
Was it illegal to blaspheme God in Antioch in 360.-410.?
In Endgame, wouldn't Stark have remembered Hulk busting out of the stairwell?
Welche normative Autorität hat der Duden? / What's the normative authority of the Duden?
Group riding etiquette
How to differentiate between two people with the same name in a story?
Ask one verbal question to figure out who is blind and who is mute among three persons
'Horseshoes' for Deer?
Is it possible for a person to be tricked into becoming a lich?
What is the practical impact of using System.Random which is not cryptographically random?
Padding a column of lists
Why don't 3D printer heads use ceramic inner walls?
Eliminate key lookup in execution plan
Which is the correct version of Mussorgsky's Pictures at an Exhibition?
Moscow SVO airport, how to avoid scam taxis without pre-booking?
New coworker has strange workplace requirements - how should I deal with them?
What are the in-game differences between WoW Classic and the original 2006 Version
What was Captain Marvel supposed to do once she reached her destination?
Proper (working) way to return an int pointer through STREAMS?
Possible missing firmwareIs there a way to expose extra settings through sysfs using the IIO framework?What is the proper way to listen on serial port using minicom?What is the proper way to start a driver on boot?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I had been doing some work with an old SVR4 box with serial i/o when I found that the driver for the serial card did not support TIOCMGET through an ioctl call (e.g. ioctl(fd, TIOCMGET, &arg);). Having the source for the driver, and looking at it - it didn't seem too hard to add an answer to the call. However, I've run into a bit of a snag in that what I am doing doesn't seem to work. Looking at the driver, it has the following code to service TCGETS:
case TCGETS:
{ /* immediate parm retrieve */
register struct termios *cb;
if (mp->b_cont) /* Bad user supplied parameter */
freemsg(mp->b_cont);
if (!(bp1 = allocb(sizeof(struct termios), BPRI_MED)))
{
putbq(q, mp);
bufcall(sizeof(struct termios), BPRI_MED, getoblk, (long)tp);
return;
}
mp->b_cont = bp1;
cb = (struct termios *)mp->b_cont->b_rptr;
cb->c_iflag = tp->t_iflag;
cb->c_oflag = tp->t_oflag;
cb->c_cflag = tp->t_cflag;
mp->b_cont->b_wptr += sizeof(struct termios);
mp->b_datap->db_type = M_IOCACK;
iocbp->ioc_count = sizeof(struct termios);
putnext(RD(q), mp);
break;
}
My thought was simply to copy this code and rather than return a termios structure, just return the int. As such, my code is similar:
case TIOCMGET:
{ /* immediate parm retrieve */
register int *cb;
if (mp->b_cont) /* Bad user supplied parameter */
freemsg(mp->b_cont);
if (!(bp1 = allocb(sizeof(int), BPRI_MED)))
{
putbq(q, mp);
bufcall(sizeof(int), BPRI_MED, getoblk, (long)tp);
return;
}
mp->b_cont = bp1;
cb = (int *)mp->b_cont->b_rptr;
/* my original attempt to get some bits */
*cb = (ql->carrier * TIOCM_CAR | ql->rts * TIOCM_RTS | (ql->lp->command & 1) * TIOCM_DTR)
/* Tried this to debug:
*cb = 0;
Doesn't seem to change the variable I pass in */
/* Tried this, compiles fine,
*(int *)mp->b_cont->b_rptr = 0;
but I get an improper argument passed error while running */
qreply(q, mp);
mp->b_cont->b_wptr += sizeof(int);
mp->b_datap->db_type = M_IOCACK;
iocbp->ioc_count = sizeof(int);
putnext(RD(q), mp);
break;
}
Making the call as shown previously, ioctl(fd, TIOCMGET, &arg), the arg value does not seem to get changed. I've tried a couple different attempts to return a value of 0 in case the problem was in my bit assignment code. However, I've not had any luck.
I did write a program to make sure that TCGETS works as it should - and it does. So I'm not sure where I'm going wrong - probably something incredibly stupid and right in front of me. Hopefully that it is SVR4 and STREAMS isn't so arcane to put an answer out of reach.
Thanks to all who look and try to help.
Mack
drivers serial-port streams svr4
New contributor
add a comment |
I had been doing some work with an old SVR4 box with serial i/o when I found that the driver for the serial card did not support TIOCMGET through an ioctl call (e.g. ioctl(fd, TIOCMGET, &arg);). Having the source for the driver, and looking at it - it didn't seem too hard to add an answer to the call. However, I've run into a bit of a snag in that what I am doing doesn't seem to work. Looking at the driver, it has the following code to service TCGETS:
case TCGETS:
{ /* immediate parm retrieve */
register struct termios *cb;
if (mp->b_cont) /* Bad user supplied parameter */
freemsg(mp->b_cont);
if (!(bp1 = allocb(sizeof(struct termios), BPRI_MED)))
{
putbq(q, mp);
bufcall(sizeof(struct termios), BPRI_MED, getoblk, (long)tp);
return;
}
mp->b_cont = bp1;
cb = (struct termios *)mp->b_cont->b_rptr;
cb->c_iflag = tp->t_iflag;
cb->c_oflag = tp->t_oflag;
cb->c_cflag = tp->t_cflag;
mp->b_cont->b_wptr += sizeof(struct termios);
mp->b_datap->db_type = M_IOCACK;
iocbp->ioc_count = sizeof(struct termios);
putnext(RD(q), mp);
break;
}
My thought was simply to copy this code and rather than return a termios structure, just return the int. As such, my code is similar:
case TIOCMGET:
{ /* immediate parm retrieve */
register int *cb;
if (mp->b_cont) /* Bad user supplied parameter */
freemsg(mp->b_cont);
if (!(bp1 = allocb(sizeof(int), BPRI_MED)))
{
putbq(q, mp);
bufcall(sizeof(int), BPRI_MED, getoblk, (long)tp);
return;
}
mp->b_cont = bp1;
cb = (int *)mp->b_cont->b_rptr;
/* my original attempt to get some bits */
*cb = (ql->carrier * TIOCM_CAR | ql->rts * TIOCM_RTS | (ql->lp->command & 1) * TIOCM_DTR)
/* Tried this to debug:
*cb = 0;
Doesn't seem to change the variable I pass in */
/* Tried this, compiles fine,
*(int *)mp->b_cont->b_rptr = 0;
but I get an improper argument passed error while running */
qreply(q, mp);
mp->b_cont->b_wptr += sizeof(int);
mp->b_datap->db_type = M_IOCACK;
iocbp->ioc_count = sizeof(int);
putnext(RD(q), mp);
break;
}
Making the call as shown previously, ioctl(fd, TIOCMGET, &arg), the arg value does not seem to get changed. I've tried a couple different attempts to return a value of 0 in case the problem was in my bit assignment code. However, I've not had any luck.
I did write a program to make sure that TCGETS works as it should - and it does. So I'm not sure where I'm going wrong - probably something incredibly stupid and right in front of me. Hopefully that it is SVR4 and STREAMS isn't so arcane to put an answer out of reach.
Thanks to all who look and try to help.
Mack
drivers serial-port streams svr4
New contributor
It's probably not enough to just add a case statement there ... you may need to add TIOCMGET to other places (also, using*
looks wrong in the original bit expression) (also, what doesqreply(q, mp)
do?)
– Murray Jensen
1 hour ago
add a comment |
I had been doing some work with an old SVR4 box with serial i/o when I found that the driver for the serial card did not support TIOCMGET through an ioctl call (e.g. ioctl(fd, TIOCMGET, &arg);). Having the source for the driver, and looking at it - it didn't seem too hard to add an answer to the call. However, I've run into a bit of a snag in that what I am doing doesn't seem to work. Looking at the driver, it has the following code to service TCGETS:
case TCGETS:
{ /* immediate parm retrieve */
register struct termios *cb;
if (mp->b_cont) /* Bad user supplied parameter */
freemsg(mp->b_cont);
if (!(bp1 = allocb(sizeof(struct termios), BPRI_MED)))
{
putbq(q, mp);
bufcall(sizeof(struct termios), BPRI_MED, getoblk, (long)tp);
return;
}
mp->b_cont = bp1;
cb = (struct termios *)mp->b_cont->b_rptr;
cb->c_iflag = tp->t_iflag;
cb->c_oflag = tp->t_oflag;
cb->c_cflag = tp->t_cflag;
mp->b_cont->b_wptr += sizeof(struct termios);
mp->b_datap->db_type = M_IOCACK;
iocbp->ioc_count = sizeof(struct termios);
putnext(RD(q), mp);
break;
}
My thought was simply to copy this code and rather than return a termios structure, just return the int. As such, my code is similar:
case TIOCMGET:
{ /* immediate parm retrieve */
register int *cb;
if (mp->b_cont) /* Bad user supplied parameter */
freemsg(mp->b_cont);
if (!(bp1 = allocb(sizeof(int), BPRI_MED)))
{
putbq(q, mp);
bufcall(sizeof(int), BPRI_MED, getoblk, (long)tp);
return;
}
mp->b_cont = bp1;
cb = (int *)mp->b_cont->b_rptr;
/* my original attempt to get some bits */
*cb = (ql->carrier * TIOCM_CAR | ql->rts * TIOCM_RTS | (ql->lp->command & 1) * TIOCM_DTR)
/* Tried this to debug:
*cb = 0;
Doesn't seem to change the variable I pass in */
/* Tried this, compiles fine,
*(int *)mp->b_cont->b_rptr = 0;
but I get an improper argument passed error while running */
qreply(q, mp);
mp->b_cont->b_wptr += sizeof(int);
mp->b_datap->db_type = M_IOCACK;
iocbp->ioc_count = sizeof(int);
putnext(RD(q), mp);
break;
}
Making the call as shown previously, ioctl(fd, TIOCMGET, &arg), the arg value does not seem to get changed. I've tried a couple different attempts to return a value of 0 in case the problem was in my bit assignment code. However, I've not had any luck.
I did write a program to make sure that TCGETS works as it should - and it does. So I'm not sure where I'm going wrong - probably something incredibly stupid and right in front of me. Hopefully that it is SVR4 and STREAMS isn't so arcane to put an answer out of reach.
Thanks to all who look and try to help.
Mack
drivers serial-port streams svr4
New contributor
I had been doing some work with an old SVR4 box with serial i/o when I found that the driver for the serial card did not support TIOCMGET through an ioctl call (e.g. ioctl(fd, TIOCMGET, &arg);). Having the source for the driver, and looking at it - it didn't seem too hard to add an answer to the call. However, I've run into a bit of a snag in that what I am doing doesn't seem to work. Looking at the driver, it has the following code to service TCGETS:
case TCGETS:
{ /* immediate parm retrieve */
register struct termios *cb;
if (mp->b_cont) /* Bad user supplied parameter */
freemsg(mp->b_cont);
if (!(bp1 = allocb(sizeof(struct termios), BPRI_MED)))
{
putbq(q, mp);
bufcall(sizeof(struct termios), BPRI_MED, getoblk, (long)tp);
return;
}
mp->b_cont = bp1;
cb = (struct termios *)mp->b_cont->b_rptr;
cb->c_iflag = tp->t_iflag;
cb->c_oflag = tp->t_oflag;
cb->c_cflag = tp->t_cflag;
mp->b_cont->b_wptr += sizeof(struct termios);
mp->b_datap->db_type = M_IOCACK;
iocbp->ioc_count = sizeof(struct termios);
putnext(RD(q), mp);
break;
}
My thought was simply to copy this code and rather than return a termios structure, just return the int. As such, my code is similar:
case TIOCMGET:
{ /* immediate parm retrieve */
register int *cb;
if (mp->b_cont) /* Bad user supplied parameter */
freemsg(mp->b_cont);
if (!(bp1 = allocb(sizeof(int), BPRI_MED)))
{
putbq(q, mp);
bufcall(sizeof(int), BPRI_MED, getoblk, (long)tp);
return;
}
mp->b_cont = bp1;
cb = (int *)mp->b_cont->b_rptr;
/* my original attempt to get some bits */
*cb = (ql->carrier * TIOCM_CAR | ql->rts * TIOCM_RTS | (ql->lp->command & 1) * TIOCM_DTR)
/* Tried this to debug:
*cb = 0;
Doesn't seem to change the variable I pass in */
/* Tried this, compiles fine,
*(int *)mp->b_cont->b_rptr = 0;
but I get an improper argument passed error while running */
qreply(q, mp);
mp->b_cont->b_wptr += sizeof(int);
mp->b_datap->db_type = M_IOCACK;
iocbp->ioc_count = sizeof(int);
putnext(RD(q), mp);
break;
}
Making the call as shown previously, ioctl(fd, TIOCMGET, &arg), the arg value does not seem to get changed. I've tried a couple different attempts to return a value of 0 in case the problem was in my bit assignment code. However, I've not had any luck.
I did write a program to make sure that TCGETS works as it should - and it does. So I'm not sure where I'm going wrong - probably something incredibly stupid and right in front of me. Hopefully that it is SVR4 and STREAMS isn't so arcane to put an answer out of reach.
Thanks to all who look and try to help.
Mack
drivers serial-port streams svr4
drivers serial-port streams svr4
New contributor
New contributor
New contributor
asked 5 hours ago
mackbwmackbw
62 bronze badges
62 bronze badges
New contributor
New contributor
It's probably not enough to just add a case statement there ... you may need to add TIOCMGET to other places (also, using*
looks wrong in the original bit expression) (also, what doesqreply(q, mp)
do?)
– Murray Jensen
1 hour ago
add a comment |
It's probably not enough to just add a case statement there ... you may need to add TIOCMGET to other places (also, using*
looks wrong in the original bit expression) (also, what doesqreply(q, mp)
do?)
– Murray Jensen
1 hour ago
It's probably not enough to just add a case statement there ... you may need to add TIOCMGET to other places (also, using
*
looks wrong in the original bit expression) (also, what does qreply(q, mp)
do?)– Murray Jensen
1 hour ago
It's probably not enough to just add a case statement there ... you may need to add TIOCMGET to other places (also, using
*
looks wrong in the original bit expression) (also, what does qreply(q, mp)
do?)– Murray Jensen
1 hour ago
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
});
}
});
mackbw is a new contributor. Be nice, and check out our Code of Conduct.
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%2f538347%2fproper-working-way-to-return-an-int-pointer-through-streams%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
mackbw is a new contributor. Be nice, and check out our Code of Conduct.
mackbw is a new contributor. Be nice, and check out our Code of Conduct.
mackbw is a new contributor. Be nice, and check out our Code of Conduct.
mackbw is a new contributor. Be nice, and check out our Code of Conduct.
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%2f538347%2fproper-working-way-to-return-an-int-pointer-through-streams%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
It's probably not enough to just add a case statement there ... you may need to add TIOCMGET to other places (also, using
*
looks wrong in the original bit expression) (also, what doesqreply(q, mp)
do?)– Murray Jensen
1 hour ago