[olug] OT? C programming question.
Cooper Vertz
olug at vertz.info
Wed Sep 1 18:34:44 UTC 2010
I think the receiver is one of these thingies:
http://www.ftionline.com/products/DVR_Instructions.pdf
*Using the PERMCH Command to dynamically change channels on the WEGENER DVR
series IRD. NOTE: all four FREQ CMD dip switches must be in the up position.
*
...
*PERMCH (spacebar) 1 & Enter – dynamically selects SCOLA Channel Seven*
And I think the problem is, you need a literal ampersand in your string.
n = write(fd, "permch 1&\r", 9);
The number of arguments to the write function seems correct,
$ man 2 write
NAME
write - write to a file descriptor
SYNOPSIS
#include <unistd.h>
ssize_t write(int fd, const void *buf, size_t count);
DESCRIPTION
write() writes up to count bytes to the file referenced by the file
descriptor fd from the
buffer starting at buf. POSIX requires that a read() which can be
proved to occur after a
write() has returned returns the new data. Note that not all file
systems are POSIX con-
forming.
RETURN VALUE
On success, the number of bytes written are returned (zero indicates
nothing was written).
On error, -1 is returned, and errno is set appropriately. If count
is zero and the file
descriptor refers to a regular file, 0 may be returned, or an error
could be detected.
For a special file, the results are not portable.
On Wed, Sep 1, 2010 at 12:23 PM, Dan Anderson <dan-anderson at cox.net> wrote:
> The "receiver" appears to be something hung off the serial port.
>
> I don't understand the problem either though.
>
> If one of the parameters (?) has an extra char, I guess I'd filter it
> (which
> you should do anyway).
>
> I'd also check to make sure that I am sending the correct cr/lf that the
> "receiver" expects (i.e. \r versus \r\n). "Enter" means different things.
>
> Dan
>
> On Wed, Sep 1, 2010 at 11:42 AM, Obi-Wan <obiwan at jedi.com> wrote:
>
> > I write C code for a living, but I'm not quite sure what you're asking
> > from us or what the current problem is. Can you elaborate?
> >
> > Is the "receiver" just a socket connection to some other program that's
> > expecting ASCII commands?
> >
>
>
> > > Â Â Â Â Â fd = open( "/dev/ttyS0", O_RDWR | O_NDELAY);
> > > Â Â Â Â Â fd = open( "/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY);
> > > This is from the user guide of the receiver (using a terminal
> emulator):
> > >
> > > Using the PERMCH Command to dynamically change channels on the
> receiver.
> > NOTE: all four FREQ CMD dip switches must be in the up position.
> > > PERMCH (spacebar) 8 & Enter – dynamically selects Channel 1
> > > PERMCH (spacebar) 12 & Enter – dynamically selects Channel 2
> > > PERMCH (spacebar) 14 & Enter – dynamically selects Channel 3
> > > PERMCH (spacebar) 15 & Enter – dynamically selects Channel 4
> > > PERMCH (spacebar) 7 & Enter – dynamically selects Channel 5
> > > PERMCH (spacebar) 3 & Enter – dynamically selects Channel 6
> > > PERMCH (spacebar) 1 & Enter – dynamically selects Channel 7
> > > PERMCH (spacebar) 5 & Enter – dynamically selects Channel 8
> >
> _______________________________________________
> OLUG mailing list
> OLUG at olug.org
> https://lists.olug.org/mailman/listinfo/olug
>
More information about the OLUG
mailing list