|
Hi
I have started adding support for the K3 in my ham radio applications for Linux. I am currently working with my xdemorse app which decodes Morse code via the sound card and can also control the transceiver (tune in a signal on the waterfall exactly by changing the frequency of the receiver). Doing this involves reading the current VFO frequency, correcting it according to the offset from the center of the waterfall and then sending it to the K3 VFO. I have gotten all this to work well (I can tune in a CW signal to the nearest 1-2 Hz just by clicking near the trace!), but in order to read data from the K3 it was necessary to invoke the posix read() command to pull data from the K3 one byte at a time, e.g. read( serial_fd, buffer, 1 ) enough times to read all the data (14 times to read the frequency with the FA; command!). Normally it should have been read( serial_fd, buffer, 14 ) to read all bytes, as it is done for the FT847/FT857 CAT. I would like to know if the above is the normal way to read the serial port of the K3 (e.g. one byte at a time), or if I am doing something wrong here. My thanks in advance. Regards Neoklis - Ham Radio Call 5B4AZ QTH Locator KM64KR Website: http://www.qsl.net/5b4az/ ______________________________________________________________ Elecraft mailing list Home: http://mailman.qth.net/mailman/listinfo/elecraft Help: http://mailman.qth.net/mmfaq.htm Post: mailto:[hidden email] This list hosted by: http://www.qsl.net Please help support this email list: http://www.qsl.net/donate.html |
|
I don't have a Unix system, so can't speak Unix to you but in my personal application written in C# I do this: do { byteRead = (byte)serialPort.ReadByte(); byteBuffer[bufferedByteCount++] = byteRead; s = Encoding.ASCII.GetString(byteBuffer, bufferedByteCount - 1, 1); } while (s != ";"); 73, Tom Amateur Radio Operator N5GE ARRL Lifetime Member QCWA Lifetime Member "Only the white eyes would believe they could cut the top off a blanket, sew it to the bottom and have a longer blanket." -- American Indian comment about Daylight Saving Time -- On Sun, 29 Jan 2012 12:34:30 -0800 (PST), Neoklis Kyriazis <[hidden email]> wrote: >Hi > >I have started adding support for the K3 in my ham radio applications for Linux. >I am currently working with my xdemorse app which decodes Morse code via >the sound card and can also control the transceiver (tune in a signal on the > >waterfall exactly by changing the frequency of the receiver). > >Doing this involves reading the current VFO frequency, correcting it according >to the offset from the center of the waterfall and then sending it to the K3 VFO. >I have gotten all this to work well (I can tune in a CW signal to the nearest 1-2 Hz >just by clicking near the trace!), but in order to read data from the K3 it was > >necessary to invoke the posix read() command to pull data from the K3 one byte >at a time, e.g. read( serial_fd, buffer, 1 ) enough times to read all the data (14 >times to read the frequency with the FA; command!). > >Normally it should have been read( serial_fd, buffer, 14 ) to read all bytes, as it >is done for the FT847/FT857 CAT. I would like to know if the above is the normal >way to read the serial port of the K3 (e.g. one byte at a time), or if I am doing >something wrong here. > >My thanks in advance. > > > >Regards Neoklis - Ham Radio Call 5B4AZ >QTH Locator KM64KR >Website: http://www.qsl.net/5b4az/ >______________________________________________________________ >Elecraft mailing list >Home: http://mailman.qth.net/mailman/listinfo/elecraft >Help: http://mailman.qth.net/mmfaq.htm >Post: mailto:[hidden email] > >This list hosted by: http://www.qsl.net >Please help support this email list: http://www.qsl.net/donate.html ______________________________________________________________ Elecraft mailing list Home: http://mailman.qth.net/mailman/listinfo/elecraft Help: http://mailman.qth.net/mmfaq.htm Post: mailto:[hidden email] This list hosted by: http://www.qsl.net Please help support this email list: http://www.qsl.net/donate.html
Amateur Radio Operator N5GE
|
|
In reply to this post by Neoklis Kyriazis
Neoklis,
I can't speak definitively on the differences between the Yaesu and the K3 serial behavior, but I can speak with knowledge on serial I/O in Linux. The read() system call "attempts to read" the number of bytes you asked for. This means that when you call it, it will immediately return whatever is already in the input buffer, up to "count" characters. If there is nothing in the input buffer, it will either wait for a character or return immediately, depending on thresholds set with the tcsetattr() call. The number of characters that it read is returned as the function value. So if you call read(serial_fd, buffer, 14), you are not guaranteed to read 14 characters. The only guarantee is that you won't read *more than* 14 characters. So there is some difference in the behavior of the Yaesu and the K3, but both behaviors are normal. You just need to keep reading until you have all the bytes you want. I wrote a function to do this: /* read n characters from fd, guaranteed */ readn(fd,buf,n) int fd; char *buf; int n; { int nchars, ret; for (nchars = 0; nchars < n; nchars += ret) { ret = read(fd,buf,n-nchars); if (ret == -1 || ret == 0) return(ret); buf += ret; } return(n); } You may also want to look at the ioctl(fd,FIONREAD,&n) call. This tells you how many bytes are pending to be read on the specified file descriptor. Good luck! 73, Andy, N2CN Neoklis Kyriazis wrote: > Hi > > I have started adding support for the K3 in my ham radio applications for Linux. > I am currently working with my xdemorse app which decodes Morse code via > the sound card and can also control the transceiver (tune in a signal on the > > waterfall exactly by changing the frequency of the receiver). > > Doing this involves reading the current VFO frequency, correcting it according > to the offset from the center of the waterfall and then sending it to the K3 VFO. > I have gotten all this to work well (I can tune in a CW signal to the nearest 1-2 Hz > just by clicking near the trace!), but in order to read data from the K3 it was > > necessary to invoke the posix read() command to pull data from the K3 one byte > at a time, e.g. read( serial_fd, buffer, 1 ) enough times to read all the data (14 > times to read the frequency with the FA; command!). > > Normally it should have been read( serial_fd, buffer, 14 ) to read all bytes, as it > is done for the FT847/FT857 CAT. I would like to know if the above is the normal > way to read the serial port of the K3 (e.g. one byte at a time), or if I am doing > something wrong here. > > My thanks in advance. > > > > Regards Neoklis - Ham Radio Call 5B4AZ > QTH Locator KM64KR > Website: http://www.qsl.net/5b4az/ > ______________________________________________________________ > Elecraft mailing list > Home: http://mailman.qth.net/mailman/listinfo/elecraft > Help: http://mailman.qth.net/mmfaq.htm > Post: mailto:[hidden email] > > This list hosted by: http://www.qsl.net > Please help support this email list: http://www.qsl.net/donate.html > Elecraft mailing list Home: http://mailman.qth.net/mailman/listinfo/elecraft Help: http://mailman.qth.net/mmfaq.htm Post: mailto:[hidden email] This list hosted by: http://www.qsl.net Please help support this email list: http://www.qsl.net/donate.html |
|
In reply to this post by Neoklis Kyriazis
* On 2012 29 Jan 14:36 -0600, Neoklis Kyriazis wrote:
> Hi > > I have started adding support for the K3 in my ham radio applications for Linux. > I am currently working with my xdemorse app which decodes Morse code via > the sound card and can also control the transceiver (tune in a signal on the > > waterfall exactly by changing the frequency of the receiver). > > Doing this involves reading the current VFO frequency, correcting it according > to the offset from the center of the waterfall and then sending it to the K3 VFO. > I have gotten all this to work well (I can tune in a CW signal to the nearest 1-2 Hz > just by clicking near the trace!), but in order to read data from the K3 it was > > necessary to invoke the posix read() command to pull data from the K3 one byte > at a time, e.g. read( serial_fd, buffer, 1 ) enough times to read all the data (14 > times to read the frequency with the FA; command!). > > Normally it should have been read( serial_fd, buffer, 14 ) to read all bytes, as it > is done for the FT847/FT857 CAT. I would like to know if the above is the normal > way to read the serial port of the K3 (e.g. one byte at a time), or if I am doing > something wrong here. As Hamlib is available for POSIX and Win32 systems, have you considered it? If the K3 support is not up to part, let me know. I'd like to improve it. The upshot for you is that you can write to a single API to control all manner of rigs. c.f. Fldigi, CQRlog, gpredict, etc. 73, de Nate, N0NB >> -- "The optimist proclaims that we live in the best of all possible worlds. The pessimist fears this is true." Ham radio, Linux, bikes, and more: http://www.n0nb.us ______________________________________________________________ Elecraft mailing list Home: http://mailman.qth.net/mailman/listinfo/elecraft Help: http://mailman.qth.net/mmfaq.htm Post: mailto:[hidden email] This list hosted by: http://www.qsl.net Please help support this email list: http://www.qsl.net/donate.html |
|
Yes, I was going to suggest hamlib, too. Once you've programmed for one
rig, you've programmed for all. It's quite a package. Nate Bargmann wrote: > As Hamlib is available for POSIX and Win32 systems, have you considered > it? If the K3 support is not up to part, let me know. I'd like to > improve it. The upshot for you is that you can write to a single API to > control all manner of rigs. c.f. Fldigi, CQRlog, gpredict, etc. ______________________________________________________________ Elecraft mailing list Home: http://mailman.qth.net/mailman/listinfo/elecraft Help: http://mailman.qth.net/mmfaq.htm Post: mailto:[hidden email] This list hosted by: http://www.qsl.net Please help support this email list: http://www.qsl.net/donate.html |
|
In reply to this post by Neoklis Kyriazis
Some links that may be helpful for you:
http://tldp.org/HOWTO/Serial-HOWTO.html http://tldp.org/HOWTO/Serial-Programming-HOWTO/ 73, David AJ4TF > ------------------------------ > > Message: 12 > Date: Sun, 29 Jan 2012 12:34:30 -0800 (PST) > From: Neoklis Kyriazis <[hidden email]> > Subject: [Elecraft] K3 programming problem > To: "[hidden email]" <[hidden email]> > Message-ID: > <[hidden email]> > Content-Type: text/plain; charset=iso-8859-1 > > Hi > > I have started adding support for the K3 in my ham radio applications for Linux. > I am currently working with my xdemorse app which decodes Morse code via > the sound card and can also control the transceiver (tune in a signal on the > > waterfall exactly by changing the frequency of the receiver). > > Doing this involves reading the current VFO frequency, correcting it according > to the offset from the center of the waterfall and then sending it to the K3 VFO. > I have gotten all this to work well (I can tune in a CW signal to the nearest 1-2 Hz > just by clicking near the trace!), but in order to read data from the K3 it was > > necessary to invoke the posix? read() command to pull data from the K3 one byte > at a time, e.g. read( serial_fd, buffer, 1 ) enough times to read all the data (14 > times to read the frequency with the FA; command!). > > Normally it should have been read( serial_fd, buffer, 14 ) to read all bytes, as it > is done for the FT847/FT857 CAT. I would like to know if the above is the normal > way to read the serial port of the K3 (e.g. one byte at a time), or if I am doing > something wrong here. > > My thanks in advance. > > > ? > Regards Neoklis - Ham Radio Call 5B4AZ > QTH Locator KM64KR > Website: http://www.qsl.net/5b4az/ > > > ------------------------------ > > Message: 13 > Date: Sun, 29 Jan 2012 15:51:13 -0600 > From: [hidden email] ______________________________________________________________ Elecraft mailing list Home: http://mailman.qth.net/mailman/listinfo/elecraft Help: http://mailman.qth.net/mmfaq.htm Post: mailto:[hidden email] This list hosted by: http://www.qsl.net Please help support this email list: http://www.qsl.net/donate.html |
| Free forum by Nabble | Edit this page |
