Afedri SDR-NET, Linrad and FLDIGI

716 views
Skip to first unread message

ea1abz

unread,
Sep 24, 2014, 4:39:17 PM9/24/14
to lin...@googlegroups.com
Hello all

I have been able to make Afredi SDR-NET, Linrad and FLDIGI work using snd-aloop ALSA module, as Leif suggested. I can get the Linrad processed audio pass to fldigi. I did not have to compile anything cause snd-aloop module seemed to be built in.

Output of linrad is routed to loopback device hw:1,0. Fldigi reads hw:1,1. I do not know is it is the right way to do it, I have not found in the Internet a proper way to do it

I have been able to decode PSK31 stations. I am not sure wether I did it ok, but I get strange behaviour when receiving HF FAX stations. I have attached an image that shows it.

What could be the origin of such "unsyncronization"?

Thanks so much.

System is Debian GNU Linux Wheezy 64 bit.
Ramiro, EA4NZ.
desastre.png

Leif Asbrink

unread,
Sep 26, 2014, 4:23:49 PM9/26/14
to lin...@googlegroups.com
Hello Ramiro,

Linrad has a fractional resampler that is used to make
input and output keep a constant time delay. This is not
a simple task since the pointers within the audio buffers
are not available. The mechanism is that Linrad looks for the
time delay from input to output and tries to change the
resampling rate (slowly) to keep the time delay constant.
You might have a look here:
http://www.sm5bsz.com/linuxdsp/usage/drm/loudsp_carrier.htm

Try to set a higher DMA rate. That would make buffers smaller
and time delay measurements within Linrad more accurate.

73

Leif
> --
> You received this message because you are subscribed to the Google Groups "Linrad" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to linrad+un...@googlegroups.com.
> To post to this group, send email to lin...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Ramiro Aceves

unread,
Sep 27, 2014, 10:25:52 AM9/27/14
to LINRAD

Thanks Leif.
I do not really know what max and min DMA values mean. I have 30-300 by default. Not sure what I should type there.
I am out home, I will try it on sunday night.

Many thanks

Ramiro

Leif Asbrink

unread,
Sep 27, 2014, 10:39:19 PM9/27/14
to lin...@googlegroups.com
Hi Ramiro,

> I do not really know what max and min DMA values mean. I have 30-300 by
> default. Not sure what I should type there.
Well, I do not know either;-)

You might set both equal and try 300,1000,3000 and see what happens.
Whether it will help or not depends on the hardware and the drive
routines. If you use Windows it might help to use Portaudio with
ASIO, WDM-KS or WASAPI.

Pierre, ON5GN has supplied a new dll for Portaudio. I will upload
it together with related stuff shortly. Pierre writes:
"palir-03.dll provides Hostapi's for MME, DirectSound, WDM-KS, WASAPI
and ASIO. The WDM-KS support with palir-03 is better than with palir-02"

The latest Linrad (on the repo) allows the user to select which dll
to use in case more than one is avalable. You might have any of these:
palir-01.dll
palir-02.dll
palir-03.dll
portaudio.dll
libportaudio.dll

Dynamic libraries create problems because they are sometimes not compatible
or simply faulty. Rather than having mysterious crasches I try to make
the problems visible to the user.....

73

Leif

Ramiro Aceves

unread,
Sep 29, 2014, 2:59:17 AM9/29/14
to LINRAD

Thanks so much Leif for the tips. I use only Linux.

After Increasing dma rate to 5000-5000 I get a very good result now. Oscillation is near imperceptible. Reducing dma leads to bigger image amplitude oscillation. I also notice that I have A/D underruns at 1500kHz sample rate. At 1000kHz everything runs smoothly. I do not know if underruns cause sudden image displacements. Do not understand really what they mean.

Tonight I will try everything again to confirm the good behaviour and post an image here.

1500 KHz is the maximum sample rate that I can set for the afedri net now. I believed that in the past I set 2 Mhz sample rate, but do not remember.

Many thanks.
Ramiro.EA4NZ

al...@4z5lv.net

unread,
Sep 29, 2014, 8:19:04 AM9/29/14
to lin...@googlegroups.com
Ramiro,
AFEDRI SDR-Net cannot work on each sample rate value you wish, no way, it can work only with the frequency that is result of integer division on main Clock frequency .
The sample rate 1500kHz - NEVER was correct for any of AFEDRI SDR receivers (only AFE822x uses oscillator 72Mhz that able to provide this sample rate)
the maximal sample rate depends on  AFEDRi SDR-Net revision:
 AFEDRI SDR-Net  with revisions 0,1 able to work up to 500kHz
 AFEDRI SDR-Net  with revisions 2.x able to work up to 1333kHz
 AFEDRI SDR-Net  with revisions 3.0 able to work up to 2000kHz

Main clock value you can see using SDR_Control or sdr_commander utility.

Please read well the SDR_Network_Control_Box_short_software_description document

So your problems with digital mode synchronization more probable connected to wrong sample rate choice ...
SDR_Control utility has embedded calculator that helps to choose closes correct value.
  
73!

Ramiro Aceves

unread,
Sep 29, 2014, 9:49:34 AM9/29/14
to LINRAD
Oh thanks Alex, I am stupid!

Mine is AFEDRI SDR-Net rev.3.0a. do you know the clock frequency of it? I do not have a handy Windows system to test the windows setup utilities.

Regards

Ramiro. EA4NZ

al...@4z5lv.net

unread,
Sep 29, 2014, 11:03:54 AM9/29/14
to lin...@googlegroups.com
Ramiro,
Most AFEDRI SDR-NEt rev.3.0 have main Clock oscillator 80.000Mhz
But if you forget it - run sdr_commander utility and you will know it for sure.

sdr_commander as well as SDR_Control can be compiled for Linux too, so absence of Windows - has no excuses :-)

73!

Ramiro Aceves

unread,
Sep 29, 2014, 11:12:20 AM9/29/14
to LINRAD
Oh, thanks, I did not know it!

Knowing that  Samplerate=Fclock/(4*N), now I know how to calculate the sample rates.

The strange thing is that Linrad does not allow me to setup sample rates over 1.5 MHz.. Perhaps I need to get a new version.

Many thanks.

Ramiro.
EA4NZ.



--

al...@4z5lv.net

unread,
Sep 29, 2014, 11:42:29 AM9/29/14
to lin...@googlegroups.com
Ramiro,
Yes I have found the same problem (maximum sample rate limitation) .
May be manual editing of :
par_netafedri    -> Sampling rate [2000000]
par_userint  -> Rx ad speed [2000000]

will allow you to overcome this problem.

Tested this hint on Windows - it is working, old Linrad 4.0 allowed to set 2000kHz, in 4.01 Leif put this strange limitation...

73!
Alex


On Wednesday, September 24, 2014 11:39:17 PM UTC+3, ea1abz wrote:

Ramiro Aceves

unread,
Sep 29, 2014, 11:49:03 AM9/29/14
to LINRAD
Oh, thanks, I only tryied to change par_netafedri and missed to do it at par_userint. Linrad refused to work that way!

Will try when I arrive home.

Thanks!

Ramiro.
EA4NZ.


--

Ramiro Aceves

unread,
Sep 29, 2014, 4:52:58 PM9/29/14
to LINRAD
Yes! I could compile the utility and see the sample rate:


debian-asus-64:/home/ramiro/sdr_commander.v6# ./sdr_commander -V
Init HID interface - Blocking I/O mode!!!
AFEDRI-SDR-Net Audio device was found!!!
Firmware version: 1030
SDR serial number: 32353F32
CPLD serial number: 50007
Main clock frequency: 80000000
USB Sample Rate: 192000
SDR IP address: 192.168.0.8
SDR IP mask: 255.255.255.0
Gateway IP address: 192.168.0.1
UDP port number: 50000
DHCP server state: 0

I get perfect images at 500 kHz sample rate. At 1MHz, sometimes images break at some places. At 2 MHz they often break.


Leif Asbrink

unread,
Sep 29, 2014, 6:49:07 PM9/29/14
to lin...@googlegroups.com
Hello Alex,

The limitation comes from the SDR-IP which I thought AFTDRI is
compatible with.

The maximum rate is 2 MHz for 16 bit data but 1.3333 MHz for
24 bit data. If this is not correct I will of course change.

I was just going to upload linrad-04.02, but I will hold it
until I know if I should allow 2 MHz for 24 bit data.
(Hardly meaningful given the dynamic range of the unit.)

It would be far more interesting to allow 3 MHz at 16 bit if
the USB link can handle the speed:-)

Dear Alex - and All. When you find something strange, please
send a posting to this mailing list or send me a mail off list.


The relevant code in this case is:
if(netafedri.format != 16 && netafedri.format != 24)return FALSE;
if(netafedri.sampling_rate < 32000)return FALSE;
if(netafedri.format == 16)
{
if(netafedri.sampling_rate > 2000001.)return FALSE;
}
else
{
if(netafedri.sampling_rate > 1333334.0)return FALSE;
}
return TRUE;

I can of course easily change it.

73

Leif

al...@4z5lv.net

unread,
Sep 29, 2014, 8:32:43 PM9/29/14
to lin...@googlegroups.com
Leif,
All AFEDRI SDR has native 16 bit sample size, 24-bit simply padded by zero - nonsense to use I support it to keep SDR-IP compatibility only.

So with 16-bit sample size AFEDRI SDR-Net rev.3 able to supply 2Mhz sample rate, oldest AFEDR SDR revisions < 3.0 able to work up to 1,333Mhz only.
AFEDRI SDR-net revision less than 2.x able to sully 500kHz only.

I think 2000Mhz is OK for all revisions - it will be up to user to know it's limits :-)

73!


On Wednesday, September 24, 2014 11:39:17 PM UTC+3, ea1abz wrote:

al...@4z5lv.net

unread,
Sep 29, 2014, 8:38:09 PM9/29/14
to lin...@googlegroups.com
Leif,
Small I have found this problem "long" time ago, but forgot to send you report, sorry.

By the way this problem when Linrad limits SDR sample rate observed for 16 bit data (I never try 24-bit - because it spend network bandwidth only).

 
73!

On Wednesday, September 24, 2014 11:39:17 PM UTC+3, ea1abz wrote:

Leif Asbrink

unread,
Sep 30, 2014, 10:05:04 PM9/30/14
to lin...@googlegroups.com
Hello Alex,

I have now removed the 24 bit option for NetAfedri, but I have not
tested the code yet. It is available on the repo:
svn checkout https://sm5...@svn.code.sf.net/p/linrad/code/trunk linrad

I had planned to upload Linrad-04.02 today, but I decided to
hold it until the issues with NetAfedri are solved.
If you have the time, please check this code:
svn checkout https://sm5...@svn.code.sf.net/p/linrad/code/trunk

73

Leif

Ramiro Aceves

unread,
Oct 1, 2014, 1:09:37 AM10/1/14
to LINRAD

Thanks Leif for the effort. Tonight I will try the new version.

Now I go work.... :-(

73, Ramiro. EA4NZ

al...@4z5lv.net

unread,
Oct 2, 2014, 12:52:36 PM10/2/14
to lin...@googlegroups.com
Hello Leif,
Sorry for delay, I tested today the new 4.02 version, at first I suppose in the future versions of AFEDRi SDR-Net the 24-bit can be real not zero padded, I am planning to build such hardware, but it is not actual for my existing SDRs
Below is my short test results:
1. 2000kHz choice now working OK
2. non standard Sound card sample rate still has no support (if you remember our emails) , so for example for AFEDRi SDR-USB-HS configured for 768kHz sample rate I cannot choose the sample rate,
as a sequence after configuration process finish I have to edit manually par_userint to insert correct value 768000.
So please add option to allow user to isert manually desired sample rate during configuration if you application cannot list this sample rate value.
After manual editing Linrad is working OK with non standard value.
3. When I try to choose Portaudio for input soud card I have sound card list for short time - after that - linrad crash.
4. When I logged in as linux user and try to configure AFEDRI USB interface (key D), linrad find SDR control interface, I can choose correct VGA = AD8369, press OK, but after Linrad boot and choose SSB mode - linrad gives error message...configuration file fail.
    If I run Linrad as root - everything is OK - strange I for sure can access SDR USB control as usual user.

5. I see there web interface files - di it is functional now?

73!

Leif Asbrink

unread,
Oct 2, 2014, 9:58:25 PM10/2/14
to lin...@googlegroups.com
Hello Alex,

> Sorry for delay, I tested today the new 4.02 version, at first I suppose in
> the future versions of AFEDRi SDR-Net the 24-bit can be real not zero
> padded, I am planning to build such hardware, but it is not actual for my
> existing SDRs
OK. I have now put the 24 bit format back and changed the limits
for the sampling rate to 6 MHz. I want Linrad to be future-safe
to some extent and the user has to know a bit about his hardware
anyway. When I try to set 3 MHz with two channels (=6MHz) the
unit will send the default 250 kHz and Linrad will show the
appropriate error message after a while.

If you can give me the command to read the actual sampling rate
in an easy to understand format (Like RFSpace specifies commands)
I will use it to inform the user what sampling speed he is really
getting.

> Below is my short test results:
> 1. 2000kHz choice now working OK
> 2. non standard Sound card sample rate still has no support (if you
> remember our emails) , so for example for AFEDRi SDR-USB-HS configured for
> 768kHz sample rate I cannot choose the sample rate,
????????
I am sure I fixed that.

Now when checking I find it is not fixed - it seems I goofed on the
repo updating. I have now made the fixes again. This time I have
verified it is on the repo.

> as a sequence after configuration process finish I have to edit manually
> par_userint to insert correct value 768000.
> So please add option to allow user to isert manually desired sample rate
> during configuration if you application cannot list this sample rate value.
> After manual editing Linrad is working OK with non standard value.
On my system it is different. I can set a non standard like 50kHz, but
if I try a higher rate like 185kHz ALSA fails. (It also fails at 192 kHz)

As it turns out I can run 185 or 192 kHz on the USB3 ports. This is another
observation saying "Do not trust your USB system!!"

> 3. When I try to choose Portaudio for input soud card I have sound card
> list for short time - after that - linrad crash.
????????
More details please.

> 4. When I logged in as linux user and try to configure AFEDRI USB interface
> (key D), linrad find SDR control interface, I can choose correct VGA =
> AD8369, press OK, but after Linrad boot and choose SSB mode - linrad gives
> error message...configuration file fail.
The way Afedri reports its identity is beyond my understanding.
After you have selected to use Afedri USB as your radio hardware you
must use the function D in the U menu to set the Afedri parameters
(VGA and freq offset)

I have verified I can run as a regulkar user.

> If I run Linrad as root - everything is OK - strange I for sure can
> access SDR USB control as usual user.

> 5. I see there web interface files - di it is functional now?
"functional" in a way - but the functions implemented are zero.

Today Linrad can efficiently process the entire HF spectrum from DC
to 30 MHz. That is a first step towards an interesting web server.

I have to choose between two projects: The web server with an
appropriate client or a Linrad Tx for things like Softrock
Ensamble and IQ+. I do not know which way to go...

I have not yet released linrad-04.02. You can find it on the repo.
It has MANY improvements over 04-01, but maybe also some new errors.

I would surely appreciate if all of the readers of this mailing
list would install the latest version and report any errors or
unexpected behaviours they would find. The repo is here:
73

Leif


al...@4z5lv.net

unread,
Oct 4, 2014, 6:16:54 AM10/4/14
to lin...@googlegroups.com
Hello Leif.

If you can give me the command to read the actual sampling rate
in an easy to understand format (Like RFSpace specifies commands)
I will use it to inform the user what sampling speed he is really
getting.

Most modern AFEDRi SDR firmware revisions have the command that allows to request Maximal possible sample rate (in single channel mode):
You should send  (over TCP protocol ) next command (it simulate SDR-IP command):

0x09  0xE0 0x02 0x3F 0x00 0x00 0x00 0x00 0x00

The answer will be something like this
0x09 0xE0 0x06 0x3F 0x80 0x84 0x1E 0x00 0x00
Where last 5 bytes are max sample rate value in LSB order - in my example it is 0x00001E8480  -> 2000000 (Hz)

If you connect to Linrad AFEDRi SDR with old firmware that does not support this command , in this case you will get from SDR ACK response

0x09 0xE0 0x06 0x1C 0x00 0x00 0x00 0x00 0x00

So you can limit maximal sample rate in this case to 1333333 Hz... (but there is 500khz limited hardware too ;-))

------------------------------------------------------------------------------------------------------------------------------------------
On my system it is different. I can set a non standard like 50kHz, but
if I try a higher rate like 185kHz ALSA fails. (It also fails at 192 kHz)

As it turns out I can run 185 or 192 kHz on the USB3 ports. This is another
observation saying "Do not trust your USB system!!"

According my experience present time we cannot trust any system not Windows nor Linux every developer implements USB standards as he likes...
For example US audio specification- does not have limitation to maximal sample rate and exact sample rate value ... it allows any
 
> 3. When I try to choose Portaudio for input soud card I have sound card
> list for short time - after that - linrad crash.
????????
More details please.

May be later to reproduce this fault I need access to my Linux server.
 
> 4. When I logged in as linux user and try to configure AFEDRI USB interface
> (key D), linrad find SDR control interface, I can choose correct VGA =
> AD8369, press OK, but after Linrad boot and choose SSB mode - linrad gives
> error message...configuration file fail.
The way Afedri reports its identity is beyond my understanding.
After you have selected to use Afedri USB as your radio hardware you
must use the function D in the U menu to set the Afedri parameters
(VGA and freq offset)


Leif I have no problem with AFEDRi identity when I use hidapi for my sdr_commander utility - by the way it is good idea to use device serial number, but this actual only if user has more than one AFEDRI connected to same PC.
When user have single SDR unit - there is no sense to make this limitation, for example sdr_commander by default does not use any serial number but address the first available USB device.
In same time sdr_commander has additional -N key that allows to use serial number to open specific AFEDRI device.
This option used when multiple AFEDRI SDR devices running with websdr server to send specific command to specific device.

So may be it can be good idea to allow user ignore serial number by default and use it - if he wants.



Today Linrad can efficiently process the entire HF spectrum from DC
to 30 MHz. That is a first step towards an interesting web server.

 
Which protocol should I use as developer to get 30Mhz from Linrad when I testing the new hardware (I have in my plans to build 30Mhz bandwidth SDR)
 
I have to choose between two projects: The web server with an
appropriate client or a Linrad Tx for things like Softrock
Ensamble and IQ+. I do not know which way to go...

TX ability and webserver both good features, so hard to advice to you which is the better - BOTH :-) 

Leif, I have an additional question:
When I want to implement my new hardware support in Linrad (not ExtIO way), what is the correct way to send to Linrad the sampled data?
For example I want to add support of AFEDRI SDR-USB-HS when it is running in Mass Storage Device mode (I call it MSD mode).
All Linrad need to control and get data from / to SDR - it is unbuffered File Read/Write operation (no network or drivers API involved).
So how can I transfer data stream to Linrad?
Extio - it is option number 1, but what is the native Linrad way to add user hardware.
When I read your Z_USERS_HWARE.txt and analyzing example files users.c etc. dat stream possibility  is not clear to me, may be it is impossible this way?

73!
Alex

Leif Asbrink

unread,
Oct 5, 2014, 7:01:18 PM10/5/14
to lin...@googlegroups.com
Hello Alex,

> Most modern AFEDRi SDR firmware revisions have the command that allows to
> request Maximal possible sample rate (in single channel mode):
.
.
My unit reports 2 MHz, but now since I have put the 24 bit data
format back it will not be correct to set the maximum speed
to 2MHz/1MHz for one or two channels.

If the 24 bit format is selected, then I can only use 1.3333/0.66666
for one or two channels. This is the same is in SDR-IP. Will it
be ok to set the limit like this:

limit=16X/(chans*bits) ?

Here X would be the reported max speed or 1333333 in case only ACK
was received.

------------------------------------------------------------------------------------------------------------------------------------------
>
>
> > On my system it is different. I can set a non standard like 50kHz, but
> > if I try a higher rate like 185kHz ALSA fails. (It also fails at 192 kHz)
> >
> > As it turns out I can run 185 or 192 kHz on the USB3 ports. This is
> > another
> > observation saying "Do not trust your USB system!!"
> >
> > According my experience present time we cannot trust any system not
> Windows nor Linux every developer implements USB standards as he likes...
> For example US audio specification- does not have limitation to maximal
> sample rate and exact sample rate value ... it allows any
No, it does not - not on the USB2 ports of my system. they do not allow
higher rates than 96 kHz or so. Arbitrary lower rates are OK. The USB3
ports on the same computer allow much higher rates.

The USB2 ports allow 5MHz or more with the Mirics dongle. It is a
compatibility problem between ALSA and the USB sub-system.

> So may be it can be good idea to allow user ignore serial number by default
> and use it - if he wants.
Maybe, but that would make the set-up logics different from how it is done
everywhere else in Linrad. To change everywhere is a lot of code-writing.

> > Today Linrad can efficiently process the entire HF spectrum from DC
> > to 30 MHz. That is a first step towards an interesting web server.
> >
> Which protocol should I use as developer to get 30Mhz from Linrad when I
> testing the new hardware (I have in my plans to build 30Mhz bandwidth SDR)
Any that would provide the bandwidth.

> Leif, I have an additional question:
> When I want to implement my new hardware support in Linrad (not ExtIO way),
> what is the correct way to send to Linrad the sampled data?
Anything is correct:-) Once you have decided an API for the new hardware
I will add the support functions needed.

> For example I want to add support of AFEDRI SDR-USB-HS when it is running
> in Mass Storage Device mode (I call it MSD mode).
I suggest you place some "files" on the mass storage device.
Then list those file names in adwav.txt with a name for parameter files
following on the same line.

When you start Linrad and press '4' you will get a list of the files.
select the one to use. (Each file could have its own sample rate.)

Linrad would expect the data stream to begin with the standard .wav file header
specifying the sampling rate, number of bits etc. Linrad will accept
infinite file sizes, it ignores the file size information in the header.
That could be a convenient way of doing preliminary tests. Linrad will
try to read at the specified rate. It may be necessary to tell Linrad
to read at e.g. 10.01 MHz if the true sampling rate is 10.00 MHz.

> All Linrad need to control and get data from / to SDR - it is unbuffered
> File Read/Write operation (no network or drivers API involved).
> So how can I transfer data stream to Linrad?
> Extio - it is option number 1, but what is the native Linrad way to add
> user hardware.
> When I read your Z_USERS_HWARE.txt and analyzing example files users.c etc.
> dat stream possibility is not clear to me, may be it is impossible this
> way?
I have not provided ways for the user to implement routines to receive
a data stream. In most cases that would involve loading libraries.

The recommended procedure is that the hardware developer modifies
the code for the most similar hardware so it would work for his new
hardware instead of whatever thing it replaces. I would then add the
new routine giving it a new name and include whatever libraries needed
in Makefile and in the configure programs.

Input from file is in rxin.c. Remove needless things, fgetpos etc.
that you do not need from "void rx_file_input(void)". It has a thread
of its own.

There is a problem with NetAfedri in Linrad. Originally One would set
the frequency as the number by which to divide the ADC clock. You
asked me to change that and just set a frequency. That is not really
acceptable. When I type in 96000 on my system I get about 96154
which is not what for example MAP65 users would expect. They should
type in 95237 instead. Can you give me the command th get the
sampling clock of the ADC so I could make Linrad display the correct
frequency. (Or alternatively the command to read the sampling frequency
that has been set so I could display that and store as the desired
sampling rate.)


73

Leif

al...@4z5lv.net

unread,
Oct 6, 2014, 4:40:17 AM10/6/14
to lin...@googlegroups.com
Hello Leif,
Thanks for the answer.


On Monday, October 6, 2014 2:01:18 AM UTC+3, SM5BSZ wrote:
.
My unit reports 2 MHz, but now since I have put the 24 bit data
format back it will not be correct to set the maximum speed
to 2MHz/1MHz for one or two channels.

If the 24 bit format is selected, then I can only use 1.3333/0.66666
for one or two channels. This is the same is in SDR-IP. Will it
be ok to set the limit like this:

limit=16X/(chans*bits)  ?

Here X would be the reported max speed or 1333333 in case only ACK
was received.

Leif , I have never measured  ability of AFEDRi SDR-Net to work 2Mhz / 24-bit , I do not know any SDR application that allows this configuration (2Mhz/24-bit), for example when I try to set Linrad to 2Mhz / 24-bit (correcting manually config).
So when I choose to start SSB ("D" key) I get "Internal error 1170"
I see not obstacle to get 2MHz/24-bit from AFEDRI, but present time it is not actual, because all current AFEDRI have "faked" 24-bit :-)
Please take in account that  AFEDRi SDR it is not SDR-IP, so it has not its limitations.

 
No, it does not - not on the USB2 ports of my system. they do not allow
higher rates than 96 kHz or so. Arbitrary lower rates are OK. The USB3
ports on the same computer allow much higher rates.

The USB2 ports allow 5MHz or more with the Mirics dongle. It is a
compatibility problem between ALSA and the USB sub-system.

Leif, till now I have never seen any PC's motherboard that is not able to work with higher sample rates with AFEDRi SDR-USB-HS receiver, I tested up to 768khz.
Even RaspBerry can do that - it is my personal experience.
I suppose that when you are talking about USB2 you are talking about HighSpeed devices only, because USB2 (as well as USB3) include lower speed devices too (I mean Full Speed and Low Speed USB devcie).
For sure USB2 Full speed device like AFEDRi SDR-Net are limited to FullSpeed bandwidth 12Mbit/s.

So according my practical experience AFEDRi SDR-USB-HS when working in USB Audio Class 1 mode provides up to 768khz sample rate with USB3 and USB2 ports on ALL motherboards i have access including RaspBerry PI.
All Linux on those boards are using ALSA for sound support. I tested it with next Linux distros:
Fedora 12, Fedora 17, Fedora 19, Raspbian (Debian Wheezy)
 
Sometimes I make my AFEDRI SDR-USB-HS websdr serve available over internet.
So may be USB devices you are tested - has some limitations or some problems with  protocol implementation?
Is well as i know there is no public available USB audio devices on the market

> So may be it can be good idea to allow user ignore serial number by default
> and use it - if he wants.
Maybe, but that would make the set-up logics different from how it is done
everywhere else in Linrad. To change everywhere is a lot of code-writing.

I have No problem... with any decision, but I see there some user access right problem and conflicts between Linrad and USB system.
Only root have no limitations.
I have not much Linux knowledge to help you in this case. Only reporting the problem.

I suggest you place some "files" on the mass storage device.
Then list those file names in adwav.txt with a name for parameter files
following on the same line.

I though about this approach...
 

Linrad would expect the data stream to begin with the standard .wav file header
specifying the sampling rate, number of bits etc. Linrad will accept
infinite file sizes, it ignores the file size information in the header.
In my present firmware the wav header is real problem, because SDR-USB-HS contains only raw data samples, by the  samples format  are same  as wav, but no header
My be I will implement some special firmware that will insert this header at the file beginning.

I have not provided ways for the user to implement routines to receive
a data stream. In most cases that would involve loading libraries.

Ok I will chek more complicated way :-) changing your sources, I thought about easier implementation using user.c 


There is a problem with NetAfedri in Linrad. Originally One would set
the frequency as the number by which to divide the ADC clock. You
asked me to change that and just set a frequency. That is not really
acceptable. When I type in 96000 on my system I get about 96154
which is not what for example MAP65 users would expect. They should
type in 95237 instead.

Yes it is !
 
Can you give me the command th get the
sampling clock of the ADC so I could make Linrad display the correct
frequency. (Or alternatively the command to read the sampling frequency
that has been set so I could display that and store as the desired
sampling rate.)


The main clock report is supported for ALL AFEDRi SDRs from the beginning, no problem you can request it from SDR.
According my ideology I allow freedom in used oscillators frequency, so any AFEDRi SDR can work with any oscillator if this frequency located in allowable by chip limits  < 80Mhz (For AFEDRi8201 and < 75Mhz for AFE822x)

To know used oscillator's frequency You should send sequence of two commands (over TCP protocol ) next command (it simulate SDR-IP command):
1-st SEND ( from PC -> to SDR) :
0x09  0xE0 0x02 0x55 0x00 0x00 0x00 0x00 0x00  //Request form SDR's EEPROM the  LSB halfword of sample rate
1-st ANSWER ( from SDR-> to PC) :

The answer will be something like this
0x09 0xE0 0x06 0x55 0x00 0xB4 0x00 0x00 0x00  //bold is actual returned value -> LSB

2-nd SEND ( from PC -> to SDR) :
0x09  0xE0 0x02 0x55 0x01 0x00 0x00 0x00 0x00  ////Request form SDR's EEPROM the  MSB halfword of sample rate
2-nd ANSWER ( from SDR-> to PC):
0x09 0xE0 0x06 0x55 0xC4 0x04 0x01 0x00 0x00  ////bold is actual returned value -> MSB
 
The result will be combined from two those answers,  something like this:
0x04 0xC4 0xB4 0x00  // This is example for 80000000 (Hz) clock


By the way you can take all this information from the available sources for sdr_commander (easier to  read).


Where last 5 bytes are max sample rate value in LSB order - in my example it is 0x00001E8480  -> 2000000 (Hz)
73

Leif

Leif Asbrink

unread,
Oct 7, 2014, 10:26:55 PM10/7/14
to lin...@googlegroups.com
Hello Alex,

> > My unit reports 2 MHz, but now since I have put the 24 bit data
> > format back it will not be correct to set the maximum speed
> > to 2MHz/1MHz for one or two channels.
> >
> > If the 24 bit format is selected, then I can only use 1.3333/0.66666
> > for one or two channels. This is the same is in SDR-IP. Will it
> > be ok to set the limit like this:
> >
> > limit=16X/(chans*bits) ?
> >
> > Here X would be the reported max speed or 1333333 in case only ACK
> > was received.
> >
> Leif , I have never measured ability of AFEDRi SDR-Net to work 2Mhz /
> 24-bit , *I do not know any SDR application that allows this configuration*
> (2Mhz/24-bit), for example when I try to set Linrad to 2Mhz / 24-bit
> (correcting manually config).
> So when I choose to start SSB ("D" key) I get "Internal error 1170"
You must also change par_userint to set the same sampling speed.
(This is a sanity test for copied parameter files from different
installations.)

You are the hardware designer. I want to apply sensible limitations
but I do not want to do something that limits the performance a
user can get. You wrote you will supply 24 bit in the future (probably)
so I put this format back. I can observe the performance of my NetAfedri
and set limitations according to my observations.

My question whether limit=16X/(chans*bits) will be OK is a question
about your system design strategy. Is the maximum speed I get from
the Afedri the maximum speed of the Ethernet link with 16 bit data
or is it the highest sampling rate for which you have supplied
code in the unit?

When a system in the future will tell Linrad that the maximum speed
is 3 MHz - does it mean that the maximum is 3 MHz for 16 bit data or
2 MHz for 24 bit data or does it mean that the maximum rate is
3 MHz regardless of whether the format is 16 or 24?

> I see not obstacle to get 2MHz/24-bit from AFEDRI, but present time it is
> not actual, because all current AFEDRI have "faked" 24-bit :-)
I have tested and it is not possible on my system. It IS actual to me since
I try to write future-safe code:-)

> Please take in account that AFEDRi SDR it is not SDR-IP, so it has not its
> limitations.
Sure. This is the big challenge. You are going to release new models with
unknown performance. I want to make Linrad fit them all.....

> > No, it does not - not on the USB2 ports of my system. they do not allow
> > higher rates than 96 kHz or so. Arbitrary lower rates are OK. The USB3
> > ports on the same computer allow much higher rates.
> >
> > The USB2 ports allow 5MHz or more with the Mirics dongle. It is a
> > compatibility problem between ALSA and the USB sub-system.
> >
> > Leif, till now I have never seen any PC's motherboard that is not able to
> work with higher sample rates with AFEDRi *SDR-USB-HS* receiver, I tested
> up to 768khz.
Well, I hereby (again) inform you that I have a modern computer that
can not even do 192 kHz when using the Net Afedri as a 4 channel USB
soundcard. It is a Supermicro X9DAi. I have tested the very latest
Debian unstable (Sid) as well as Debian stable (Wheezy), Fedora 20
as well as Fedora 17. They all behave the same:
Afedri USB works fine at 48 kHz on both USB2 and USB3 ports.
It does NOT work on any USB port at 185kHz. Perseus works
fine at 2 MHz on all USB ports.

Testing with my old Afedri, one channel, 192 kHz, works fine
on the USB3 ports, but only one of the four USB2 ports works.

I have two PCIe cards with USB3 ports. One does not work at
all in Linux, the other allows me to set up Linrad for
Afedri and Perseus. But it does not work. Neither for Perseus
nor for Afedri.

> Even RaspBerry can do that - it is my personal experience.
> I suppose that when you are talking about USB2 you are talking about
> HighSpeed devices only, because USB2 (as well as USB3) include lower speed
> devices too (I mean Full Speed and Low Speed USB devcie).
> For sure USB2 Full speed device like AFEDRi *SDR-Net *are limited to
> FullSpeed bandwidth 12Mbit/s.
There is something very wrong with my system. It works fine
on both USB2 and USB3 at 8MHz/35 MHz if I remember correctly.
(I can not verify, my bladeRF is broken.)

I have an Intel D5400XS motherboard and it shows the same behaviour.

> So according my practical experience AFEDRi SDR-USB-HS when working in USB
> Audio Class 1 mode provides up to 768khz sample rate with USB3 and USB2
> ports on ALL motherboards i have access including RaspBerry PI.
> All Linux on those boards are using ALSA for sound support. I tested it
> with next Linux distros:
> Fedora 12, Fedora 17, Fedora 19, Raspbian (Debian Wheezy)

AFEDRi SDR-USB-HS?? My NetAfedri presents itself as: "AFEDRI-SDR-Net Audio,
USB Audio" I have never upgraded its firmware. Something is very wrong.
The USB ports work well with several high speed SDR units that use libusb-1.0
so I must conclude that the problem is in ALSA (the USB sound module) or
perhaps pulseaudio. The error could also be the way Linrad interfaces
to ALSA, but that seems less likely since Linrad can also interface to
ALSA through Portaudio and that does not work either.

> Sometimes I make my AFEDRI SDR-USB-HS websdr serve available over internet.
> So may be USB devices you are tested - has some limitations or some
> problems with protocol implementation?
> Is well as i know there is no public available USB audio devices on the
> market
I have a Soundblaster Live 24 bit USB soundcard. It is limited to
96 kHz, but it works fine in Linux - but it can only be used as a 16 bit
card.

> > I have No problem... with any decision, but I see there some user access
> right problem and conflicts between Linrad and USB system.
> Only root have no limitations.
> I have not much Linux knowledge to help you in this case. Only reporting
> the problem.
Hmmm, I do not understand the problem.

> I suggest you place some "files" on the mass storage device.
> > Then list those file names in adwav.txt with a name for parameter files
> > following on the same line.
> >
> > I though about this approach...
>
> > Linrad would expect the data stream to begin with the standard .wav file
> > header
> > specifying the sampling rate, number of bits etc. Linrad will accept
> > infinite file sizes, it ignores the file size information in the header.
> >
> In my present firmware the wav header is real problem, because SDR-USB-HS
> contains only raw data samples, by the samples format are same as wav,
> but no header
> My be I will implement some special firmware that will insert this header
> at the file beginning.
You could easily change init_wavread to return 0 if open was sucessful.
it is in modesub.c.

> To know used oscillator's frequency You should send sequence of two
> commands (over TCP protocol ) next command (it simulate SDR-IP command):
> 1-st SEND ( from PC -> to SDR) :
> 0x09 0xE0 0x02 0x55 0x00 0x00 0x00 0x00 0x00 //Request form SDR's EEPROM
.
.
.
Excellent:-) Now users will get the proper sampling frequency displayed:-)

> By the way you can take all this information from the available sources for
> sdr_commander (easier to read).
I have tried, but I am not clever enough:-(

There is one more problem for me: How do I set the mode? Channel1,
channel2 or both channels? (Linrad can not support two channels on different
frequencies.)

73

Leif

Ramiro Aceves

unread,
Oct 8, 2014, 4:08:13 AM10/8/14
to LINRAD

Hello Leif .

It would be a nice feature that Linrad will show the available and right  sampling rates for the afedri.  I mean, not needing a calculator to find the right ones depending on the clock speed. After cheking the AFEDRI clock speed of the unit, Linrad would show a list of the available sampling speeds for the user to choose.


Thanks.

Ramiro, EA4NZ

al...@4z5lv.net

unread,
Oct 8, 2014, 6:59:15 AM10/8/14
to lin...@googlegroups.com
Hello Leif,
I don't want to overload you with tasks or features that is not actual present time :-)


On Wednesday, October 8, 2014 5:26:55 AM UTC+3, SM5BSZ wrote:
You are the hardware designer. I want to apply sensible limitations
but I do not want to do something that limits the performance a
user can get. You wrote you will supply 24 bit in the future (probably)
so I put this format back.
 I suppose you leave meanwhile your 24-bit realization, may leave to me possibility to set higher sample rate by editing par_userint or something like this. 

My question whether limit=16X/(chans*bits) will be OK is a question
about your system design strategy.
Yes It is OK maximum sample speed limited by 100Mbit/s Ethernet throuput.
But may be some limits existing in my current hardware too - I simply did not tested it.
Is the maximum speed I get from
the Afedri the maximum speed of the Ethernet link with 16 bit data
I suppose it is maximum theoretical speed of 100mbit Ethernet network

or is it the highest sampling rate for which you have supplied
code in the unit?

The maximal acceptable sample rate value in AFEDRi SDR-NEt rev.3.0 (please pay attention that on older models it will be lower)
2000khz it is not checked for bits-per-sample value, so no internal limits.
By the way 2000kHz limitation - it is AFEDRI8201 chip limit (TI promises up to 2500kHz but I have no success to get it working)
 
When a system in the future will tell Linrad that the maximum speed
is 3 MHz - does it mean that the maximum is 3 MHz for 16 bit data or
2 MHz for 24 bit data or does it mean that the maximum rate is
3 MHz regardless of whether the format is 16 or 24?

I do no think it is possible to get 3Mhz from TI front ends, but in dual channel mode I expect to have 2 channels x 2MHz (each)  - it is impossible with 100Mbit/s network, but USB2 HighSpeed allows it.  
I have tested and it is not possible on my system. It IS actual to me since
I try to write future-safe code:-)

Ok I have no comments everything is possible, I did not tested this issue.
> work with higher sample rates with AFEDRi *SDR-USB-HS* receiver, I tested
> up to 768khz.
Well, I hereby (again) inform you that I have a modern computer that
can not even do 192 kHz when using the Net Afedri as a 4 channel USB
soundcard. It is a Supermicro X9DAi.
 Leif - at first you do not have AFEDRI SDR on your hands that is able to get this throughput - all AFEDRI SDR and AFEDRI SDR-Net are USB Full Speed evice so you cannot get from them more than 250kHz sample rate
 Please pay attention that I am talking about the new model AFEDRi SDR-USB-HS , it is not SDR that you have :-) you can see the picture here:
http://afedri-sdr.com/images/AFEDRI_SDR-USB-HS_640.jpg
I have tested the very latest
So have o possibility to test it till I will send to you the specific firmware
 
Debian unstable (Sid) as well as Debian stable (Wheezy), Fedora 20
as well as Fedora 17. They all behave the same:
Afedri USB works fine at 48 kHz on both USB2 and USB3 ports.
It does NOT work on any USB port at 185kHz. Perseus works
fine at 2 MHz on all USB ports.

No-no-no please do not try it with AFEDRi SDR's you have - nonsense.
I have no porblem to run Linrad under Linux with the AFEDRi SDR-USB-HS
only one issue with linrad - I need manually correct the sample rate 768kHz (or 38kHz)

Testing with my old Afedri, one channel, 192 kHz, works fine
on the USB3 ports, but only one of the four USB2 ports works.

It is possible and known issue with Full Speed USb support by some manufacturers, I suppose it is most problem related to USB HUB.
But I am talking now about different SDR - that has HighSpeed interface theoretically able to supply up to 480Mbit/s (do not believe I can)
 
There is something very wrong with my system. It works fine
on both USB2 and USB3 at 8MHz/35 MHz if I remember correctly.
(I can not verify, my bladeRF is broken.)

 Everithing is OK with your system, please read explanation about.


> So according my practical experience AFEDRi SDR-USB-HS when working in USB
> Audio Class 1 mode provides up to 768khz sample rate with USB3 and USB2
 
USB Audio" I have never upgraded its firmware. Something is very wrong.

Everuithing is OK you do not have  AFEDRi SDR-USB-HS so even if you want you cannot test it on your system.

> Only root have no limitations.
> I have not much Linux knowledge to help you in this case. Only reporting
> the problem.
Hmmm, I do not understand the problem.

After I successfully finish all needed configuration steps (including "D" key press / choosing AD8369 and saving .
When I try to start SSB mode reception - Linuxs reports that it cannot find AFEDRI definition... when I do it as regular user, it ok when I start reception as root.

 
You could easily change init_wavread to return 0 if open was sucessful.
it is in modesub.c.
There is additional requirement to my vitrual files read - it must beopened for  unbuffered ( O_DIRECT )  read/write operations, like this:
msd_handle = open(tmp_name, O_DIRECT | O_SYNC | O_RDWR);

Excellent:-) Now users will get the proper sampling frequency displayed:-)

 
> By the way you can take all this information from the available sources for
> sdr_commander (easier to  read).
I have tried, but I am not clever enough:-(

I am not programmer, so my  comments ability is close to absolute ZERO
But I thought I got to all relevant function self explanatory names
the file fe_interface.c - contain all of them.
By the way all HID commands can be sent using SDR-IP protocol - the packet samples I gave to you use this feature.

There is one more problem for me: How do I set the mode? Channel1,
channel2 or both channels? (Linrad can not support two channels on different
frequencies.)

Yes there is such command not due to hradware difference not all command thaqt can be used for AFE822x SDR-Net (the new Dual channel SDR hardware) has effect on AFEDRI SDR-Net x2  (SDR that you have)
For example AFEDRI SDR-Net can be started in Single Channel mode only with one specific channel  (upper antenna connector). AFE822x SDR-Net allow to use any single channel.

73! Alex
 

al...@4z5lv.net

unread,
Oct 8, 2014, 7:07:44 AM10/8/14
to lin...@googlegroups.com
Hello Ramiro,


On Wednesday, October 8, 2014 11:08:13 AM UTC+3, ea1abz wrote:

Hello Leif .

It would be a nice feature that Linrad will show the available and right  sampling rates for the afedri.  I mean, not needing a calculator to find the right ones depending on the clock speed. After cheking the AFEDRI clock speed of the unit, Linrad would show a list of the available sampling speeds for the user to choose.


I want to point your attention that it will be almost endless available sample frequency list, do you really need it see and list non stop?
Usually user uses one or two predefined value. No need to open calculator every time. In addition SDR_Network_Control_Box utility (ExtIO plugin) has embedded calculator that shows you closest correct value when you input desired sample rate, you can correct it using recommended value.
And most important - to have huge application compatibility user sometime required to "cheat" software with expected value - for example  CW Skimmer . The "payment" for the "cheating" - is frequency indication error , that is minimal (zero) in the center of reception band and lineary increased when you are going to the band edges.
Additional trouble - possible with some digital modes.

  73!
Alex
Message has been deleted

al...@4z5lv.net

unread,
Oct 8, 2014, 7:30:30 AM10/8/14
to lin...@googlegroups.com
On Wednesday, October 8, 2014 5:26:55 AM UTC+3, SM5BSZ wrote:

There is one more problem for me: How do I set the mode? Channel1,
channel2 or both channels? (Linrad can not support two channels on different
frequencies.)

command code -------
                              |
0x09  0xE0 0x02 0x30 0x01 0x00 0x00 0x00 0x00  ////Set desired mode
                                   ^         ^
                                   |          |
The new mode -------------           |
The channel number ----------------

The SDR answer is ACK command with command code 0x30, the channel number can be left zero - for Dual Channel SDR (it is actual for 4 channel models)

The possible SDR modes are next:
        #define DUAL_CHANNEL_MODE_OFF 0 //Single channel mode
    #define DIVERSITY_MODE 1  
    #define DUAL_CHANNEL_MODE 2
    #define DIVERSITY_INTERNAL_ADD_MODE 3  //there SDR sends summary signal added for two channels , with possible phase shift between channels regulated
    #define QUAD_DIVERSITY_MODE 4
    #define QUAD_CHANNEL_MODE 5

Leif, if you are planning to support only Diversity mode so you can simply send DIVERSITY_MODE = 1.

73! Alex

Leif Asbrink

unread,
Oct 8, 2014, 8:39:42 AM10/8/14
to lin...@googlegroups.com, Ramiro Aceves
Hi Ramiro,

There are about 2460 possible clock speeds.
80000000/N where N is a number from 40 to 2500.

Try the latest on the repo. Type in a value, Linrad will
select the nearest frequency available and display it.

Your unit might have another frequency than 80 MHz, Linrad
will use the correct frequency for your unit and also display it.

73

Leif

Ramiro Aceves

unread,
Oct 8, 2014, 9:36:43 AM10/8/14
to LINRAD
Thanks so much, Leif. I will try the latest Linrad. Now I have 4.01
(My Afedri is 80 MHz)

73, Ramiro.EA4NZ.


Ramiro Aceves

unread,
Oct 8, 2014, 9:44:57 AM10/8/14
to LINRAD
Oh yes, I am stupid. Frequency list is very big. Leif has solved it by setting the nearest available frequency to the desired one.

73!


--

Leif Asbrink

unread,
Oct 8, 2014, 10:03:59 AM10/8/14
to lin...@googlegroups.com
Hello Alex,

> I suppose you leave meanwhile your 24-bit realization, may leave to me
> possibility to set higher sample rate by editing par_userint or something
> like this.
Yes.

> > My question whether limit=16X/(chans*bits) will be OK is a question
> > about your system design strategy.
>
> Yes It is OK maximum sample speed limited by 100Mbit/s Ethernet throuput.
> But may be some limits existing in my current hardware too - I simply did
> not tested it.
OK, I will leave it like this. When you introduce gigabit Ethernet
I will have to change;-)

> Leif - at first you do not have AFEDRI SDR on your hands that is able to
> get this throughput - all *AFEDRI SDR *and *AFEDRI SDR-Net *are USB Full
> Speed evice so you cannot get from them more than 250kHz sample rate
Oooh!! Let us drop this...


> > Only root have no limitations.
> > > I have not much Linux knowledge to help you in this case. Only reporting
> > > the problem.
> > Hmmm, I do not understand the problem.
> >
> > After I successfully finish all needed configuration steps (including "D"
> key press / choosing AD8369 and saving .
> When I try to start SSB mode reception - Linuxs reports that it cannot find
> AFEDRI definition... when I do it as regular user, it ok when I start
> reception as root.
That is an error in the message. The problem is caused by these
statements:
fe_handle=hid_open_path(cur_dev->path);
if(fe_handle == NULL)lirerr(1390);

I have now added a separate error message for this error (1393)

If you know how a normal user can get permission, please tell
me and I will put that into the error message.

> > You could easily change init_wavread to return 0 if open was sucessful.
> > it is in modesub.c.
> >
> There is additional requirement to my vitrual files read - it must beopened
> for unbuffered ( *O_DIRECT ) * read/write operations, like this:
> msd_handle = open(tmp_name, *O_DIRECT* | O_SYNC | O_RDWR);
Change in modesub.c here:
file = fopen("adwav", "rb");
if (file == NULL)
{
file = fopen("adwav.txt", "rb");
if (file == NULL)
{
empty_error:;
help_message(313);
return 1;
}
}

Then add return 0 here:
// Read the WAV file header.


73

Leif

al...@4z5lv.net

unread,
Oct 8, 2014, 11:45:19 AM10/8/14
to lin...@googlegroups.com
Leif,


On Wednesday, October 8, 2014 5:03:59 PM UTC+3, SM5BSZ wrote:
OK, I will leave it like this. When you introduce gigabit Ethernet
I will have to change;-)

Or Gigabite Ehternet or USB3 :-)
 
>  Leif - at first you do not have AFEDRI SDR on your hands that is able to
> get this throughput - all *AFEDRI SDR *and *AFEDRI SDR-Net *are USB Full
> Speed evice so you cannot get from them more than 250kHz sample rate
Oooh!! Let us drop this...


No problem only please allow users to insert its custom sample rate (even if ALSA gives some strange errors) - Linux will accept it - it is tested not only by me.

That is an error in the message. The problem is caused by these
statements:
fe_handle=hid_open_path(cur_dev->path);
if(fe_handle == NULL)lirerr(1390);

I have now added a separate error message for this error (1393)

If you know how a normal user can get permission, please tell
me and I will put that into the error message.

The problem more strange - because:
1. Linrad had access to AFEDRI HID device during configuration (pressing "D" key.)
 
Change in modesub.c here:
file = fopen("adwav", "rb");
if (file == NULL)
  {
  file = fopen("adwav.txt", "rb");
  if (file == NULL)
    {
empty_error:;
    help_message(313);
    return 1;
    }
  }  

Then add return 0 here:
// Read the WAV file header.


 
Simple usage of fopen function is problematic with device requiring unbuffered read operation, usually OS will read the file cash with same samples instead to request samples from the device.
I have found the way how to use fopen() opened file, but this requires additionals steps during file read procedure - to cancel cash.
Usage of file handle opened with open () function and O_DIRECT flag makes process easier and working evriwhere.
But I am sure you need not to change your code that is working with wav files .
may be I can change my linrad exemplar for experiments :-)

73!
Alex

Leif Asbrink

unread,
Oct 8, 2014, 6:44:34 PM10/8/14
to lin...@googlegroups.com
Hi Alex,

> > No problem only please allow users to insert its custom sample rate (even
> if ALSA gives some strange errors) - Linux will accept it - it is tested
> not only by me.
Yes, it has been in place for some time now.

Besides listing all acceptable standard rates Linrad
will also list the highest and the lowest rate that was
detected. If I set my Afedri to e.g. 185 kHz there is only
one option on the list:-)

> That is an error in the message. The problem is caused by these
> > statements:
> > fe_handle=hid_open_path(cur_dev->path);
> > if(fe_handle == NULL)lirerr(1390);
> >
> > I have now added a separate error message for this error (1393)
> >
> > If you know how a normal user can get permission, please tell
> > me and I will put that into the error message.
> >
> > The problem more strange - because:
> 1. Linrad had access to AFEDRI HID device during configuration (pressing
> "D" key.)
That was read access by
devs = hid_enumerate(afedriusb.vid, afedriusb.pid);
This is permitted for a regular user.
The "D" function does not try to get a handle.

> > Change in modesub.c here:
> > file = fopen("adwav", "rb");
> > if (file == NULL)
> > {
> > file = fopen("adwav.txt", "rb");
> > if (file == NULL)
> > {
> > empty_error:;
> > help_message(313);
> > return 1;
> > }
> > }
> >
> > Then add return 0 here:
> > // Read the WAV file header.
> >
> >
> >
> Simple usage of fopen function is problematic with device requiring
> unbuffered read operation, usually OS will read the file cash with same
> samples instead to request samples from the device.
> I have found the way how to use fopen() opened file, but this requires
> additionals steps during file read procedure - to cancel cash.
> Usage of file handle opened with open () function and O_DIRECT flag makes
> process easier and working evriwhere.
> But I am sure you need not to change your code that is working with wav
> files .
> may be I can change my linrad exemplar for experiments :-)
This is what I was suggesting. Change anything the way you
like. Once you have something that works, tell me in which files
you made changes and I will merge it with the standard version.

Do not worry about your code not working with disk file input:-)

73

Leif

al...@4z5lv.net

unread,
Oct 9, 2014, 2:31:15 AM10/9/14
to lin...@googlegroups.com
Hello Leif,

On Thursday, October 9, 2014 1:44:34 AM UTC+3, SM5BSZ wrote:
Hi Alex,

Besides listing all acceptable standard rates Linrad
will also list the highest and the lowest rate that was
detected. If I set my Afedri to e.g. 185 kHz there is only
one option on the list:-)

By the way when during configuration Linrad prints ALSA sound device property it shows AFEDRI sample rate in correct way i.e.
185185   or 768000 Hz
The problem was detected on second stage - sampel rate choice.
By the way for all present AFEDRI SDR-Net most correct way it is automatically choose listed in sound card property sample rate.
In any case SDR will not work on any other, in reality user have no possibility to choose the sample rate for USB audio device in current AFEDRI SDR implementation.
That was read access by
devs = hid_enumerate(afedriusb.vid, afedriusb.pid);
This is permitted for a regular user.
The "D" function does not try to get a handle.
 

OK, strange behavior - because when using sdr_commander utility thta allows SDR control from command shell,
the same user can open for read/write AFEDRI HID device using hidapi library (for sure I need to give access to device for user).
By the way I have found that when AFEDRI was used with sdr_commander (hidapi utility) - Linrad cannot "find" AFEDRI even if started as root.
So there is conflict between sdr_commander and Linrad - no big deal (because Linrad user does not need to use sdr_commander) , but may be it is the sign of same problem.


73!
Alex

Leif Asbrink

unread,
Oct 9, 2014, 11:28:56 AM10/9/14
to lin...@googlegroups.com
Hi Alex,

> > By the way when during configuration Linrad prints ALSA sound device
> property it shows AFEDRI sample rate in correct way i.e.
> 185185 or 768000 Hz
> The problem was detected on second stage - sampel rate choice.
> By the way for all present AFEDRI SDR-Net most correct way it is
> automatically choose listed in sound card property sample rate.
> In any case SDR will not work on any other, in reality user have no
> possibility to choose the sample rate for USB audio device in current
> AFEDRI SDR implementation.
????????
I just verified that I can set 50000 for my NetAfedri.

Did you really try the latest on the repo?
This will become the released linrad-04.02 some day.

> OK, strange behavior - because when using sdr_commander utility thta allows
> SDR control from command shell,
> the same user can open for read/write AFEDRI HID device using hidapi
> library (for sure I need to give access to device for user).
Now Linrad shows the name of the device it can not open.
In my case /dev/hidraw1 sometimes, other times /dev/hidraw0

After I used chmod to change permissions I can now run Afedri USB
as a regular user with Linrad.

> By the way I have found that when AFEDRI was used with sdr_commander
> (hidapi utility) - Linrad cannot "find" AFEDRI even if started as root.
> So there is conflict between sdr_commander and Linrad - no big deal
> (because Linrad user does not need to use sdr_commander) , but may be it is
> the sign of same problem.

As a regular user I can select Afedri as the soundcard and
and run a first instance of Linrad. I can start a second instance
of Linrad telling it to use the Intel souncard with Afedri USB
as the soundcard hardware. When both instances of Linrad are
running simultaneously I can control the frequency in one or the
other instance of Linrad so I see no reason why it should not be
possible to use sdr_commander. Probably one has to run all
programs as the same user however.

One problem remains however. How to get the device created
with the proper permissions after a reboot. Maybe udev rules
or something.

Maybe someone could suggest a suitable text to place
in the error message?

73

Leif

al...@4z5lv.net

unread,
Oct 9, 2014, 2:10:40 PM10/9/14
to lin...@googlegroups.com
Hello Leif,

On Thursday, October 9, 2014 6:28:56 PM UTC+3, SM5BSZ wrote:
...I just verified that I can set 50000 for my NetAfedri.

Did you really try the latest on the repo?
svn checkout https://sm5...@svn.code.sf.net/p/linrad/code/trunk linrad

This will become the released linrad-04.02 some day.
 
Leif, sorry, it was my fault and laziness, I've just compiled latest sources and can approve that now 768000 Hz sample rate is working as well as any other.
Many thanks!
The problem has been solved .

Now Linrad shows the name of the device it can not open.
In my case /dev/hidraw1 sometimes, other times /dev/hidraw0

After I used chmod to change permissions I can now run Afedri USB
as a regular user with Linrad.

This problem still there :-) root has no problems, user

 
 

As a regular user I can select Afedri as the soundcard and
and run a first instance of Linrad. I can start a second instance
of Linrad telling it to use the Intel souncard with Afedri USB
as the soundcard hardware. When both instances of Linrad are
running simultaneously I can control the frequency in one or the
other instance of Linrad so I see no reason why it should not be
possible to use sdr_commander. Probably one has to run all
programs as the same user however.

 
  Leif I suppose that the difference is  that  we are using different API to work with HID device.
 For example to give access to HID device with HIDAPI  functions it is enough to allow user access to USB device with specific VID and PID


One problem remains however. How to get the device created
with the proper permissions after a reboot. Maybe udev rules
or something.

 For example I put in Fedora 17 Linux:  /etc/udev/rules.d/   folder next file (91-afedriusb.rules), that contains next text:

SUBSYSTEM=="usb", ATTRS{idVendor}=="255d", ATTRS{idProduct}=="0006", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="255d", ATTRS{idProduct}=="0002", MODE="0666"


73!
Alex

Leif Asbrink

unread,
Oct 12, 2014, 10:01:37 PM10/12/14
to lin...@googlegroups.com
Hello Alex,

This is now implemented (I hope.) I have been at the Italian
digital meeting over the weekend and I did not really
have the time to test before I left home.

73

Leif



> On Wednesday, October 8, 2014 5:26:55 AM UTC+3, SM5BSZ wrote:
> >
> >
> > There is one more problem for me: How do I set the mode? Channel1,
> > channel2 or both channels? (Linrad can not support two channels on
> > different
> > frequencies.)
> >
> > command code -------
> |
> 0x09 0xE0 0x02* 0x30* *0x01* *0x00* 0x00 0x00 0x00 ////Set desired mode
> ^ ^
> | |
> The new mode ------------- |
> The channel number ----------------
>
> The SDR answer is ACK command with command code 0x30, the channel number
> can be left zero - for Dual Channel SDR (it is actual for 4 channel models)
>
> The possible SDR modes are next:
> #define DUAL_CHANNEL_MODE_OFF 0 //Single channel mode
>
> #define DIVERSITY_MODE 1
>
> #define DUAL_CHANNEL_MODE 2
>
> #define DIVERSITY_INTERNAL_ADD_MODE 3 //there SDR sends summary signal added for two channels , with possible phase shift between channels regulated
>
> #define QUAD_DIVERSITY_MODE 4
>
> #define QUAD_CHANNEL_MODE 5
>
>
> Leif, if you are planning to support only Diversity mode so you can simply send DIVERSITY_MODE = 1.
>
> 73! Alex
>
>

Leif Asbrink

unread,
Oct 12, 2014, 10:01:39 PM10/12/14
to lin...@googlegroups.com
Hello Alex,

> Leif I suppose that the difference is that we are using
> different API
> to work with HID device.
> For example to give access to HID device with HIDAPI functions it is
> enough to allow user access to USB device with specific VID and PID
Maybe. I know nothing about this. M. J. Keehan provided the HID
interface for Linrad as part of his code for the Funcube PRO+

I just used the same for Afedri.....

> > One problem remains however. How to get the device created
> > with the proper permissions after a reboot. Maybe udev rules
> > or something.
> >
> For example I put in Fedora 17 Linux: /etc/udev/rules.d/ folder next
> file (91-afedriusb.rules), that contains next text:
>
> SUBSYSTEM=="usb", ATTRS{idVendor}=="255d", ATTRS{idProduct}=="0006",
> MODE="0666"
> SUBSYSTEM=="usb", ATTRS{idVendor}=="255d", ATTRS{idProduct}=="0002",
> MODE="0666"

I thrid this in Debian in /lib/udev/rules.d/ but this did not give
a regular user access to hidraw device files. Modprobe as root after
every reboot solves the problem. There must be another way.....

73

Leif






>
>
> 73!
> Alex

al...@4z5lv.net

unread,
Oct 13, 2014, 4:03:59 AM10/13/14
to lin...@googlegroups.com
Leif,
In the beginning Ime too had problems to implement automatic user access to USB device,
please pay attention that in my example HEX number are written in low case, when it was wrote in upper case - this did not work for me.


On Monday, October 13, 2014 5:01:39 AM UTC+3, SM5BSZ wrote:
 
Maybe. I know nothing about this. M. J. Keehan provided the HID
interface for Linrad as part of his code for the Funcube PRO+

I just used the same for Afedri.....


By the way I am using HIDAPI signal11 : http://www.signal11.us/oss/hidapi/
As I can understand it is not using hidraw but directly uses libusb1.0 API.
May be this makes difference in our implementations.

May be it is same, but I am sure there is big difference - I do not have any problem with user access to AFEDRI HID device if udev rules are applied.
And most important not modprobe needed - everything is wokring just fine right after reboot as well as with Windows

 
> > One problem remains however. How to get the device created
> > with the proper permissions after a reboot. Maybe udev rules
> > or something.
> >
> For example I put in Fedora 17 Linux:  /etc/udev/rules.d/   folder next
> file (91-afedriusb.rules), that contains next text:
>
> SUBSYSTEM=="usb", ATTRS{idVendor}=="255d", ATTRS{idProduct}=="0006",
> MODE="0666"
> SUBSYSTEM=="usb", ATTRS{idVendor}=="255d", ATTRS{idProduct}=="0002",
> MODE="0666"

I thrid this in Debian in /lib/udev/rules.d/ but this did not give
a regular user access to hidraw device files. Modprobe as root after
every reboot solves the problem. There must be another way.....
 
Very probable hidraw requires different approach, the way I described described  in all Linux helps/FAQs  I've found on internet.
The HEX numbers case - is very important (it should be same as in my example) !

Second thing - may be Debian has different place (folder)  to put udev rules?
But on Raspbian and Fedora this working.
73!
Alex
 

Mike Keehan

unread,
Oct 13, 2014, 5:15:30 AM10/13/14
to lin...@googlegroups.com
Hi Leif,

Which module do you have to modprobe after reboot?

Mike.

Leif Asbrink

unread,
Oct 13, 2014, 10:02:46 AM10/13/14
to lin...@googlegroups.com
Hello Mike,

Sorry, typo. Not modprobe. I have to use chmod as root
on /dev/hidraw0 or sometimes /dev/hidraw1 to allow a
regular user access to the devices.

The problem is how to make those devices permitted for
regular users automatically after a reboot.

73

Leif
Message has been deleted

al...@4z5lv.net

unread,
Oct 13, 2014, 1:20:50 PM10/13/14
to lin...@googlegroups.com
Leif,
Please think about use of HIDAPI (from signal11) - I provided the link to you.
May be using new API you can  forget about thinking how to get access to /dev/hidraw every time after reboot

It is very easy to use/add HIDAPI to any project.
 If FunCube uses HID device it will be good for FunCube too

73!
Alex

Leif Asbrink

unread,
Oct 13, 2014, 8:38:05 PM10/13/14
to lin...@googlegroups.com
Hello Alex,

> Please think about use of HIDAPI (from signal11) - I provided the link to
> you and forget about thinking how to rename /dev/hidraw
> It is very easy to use/add HIDAPI to any project.
> If FunCube uses HID device it will be good for FunCube too

This is yet another problem with no interest from a signal
processing or radio view. If you think it is easy, please modify
the Linrad source code; replace hid.c and hidwin.c with the
signal11 routine(s).

Best if hid.c and hidwin.c could be identical with appropriate
usage of #if OSNUM == OSNUM_WINDOWS and #if OSNUM == OSNUM_LINUX

I will spend my time on more radio-oriented problems, but
I would surely be happy to include improvements on computer-
oriented problems. (I always run as root so there are many
problems I never see. I recommend amateurs to run Linrad as root,
there are permission problems with several other hardware.)

73

Leif

Ramiro Aceves

unread,
Oct 14, 2014, 4:08:32 AM10/14/14
to LINRAD
Hello

Just to say that I fetched the repo last sources and Afedri setup worked with your last improvements.

My system is now Debian Jessie.

Many thanks for the effort.

Ramiro.
EA4NZ.


Mike Keehan

unread,
Oct 14, 2014, 5:59:15 AM10/14/14
to lin...@googlegroups.com
Hi Alex,

The Funcube code in Linrad _is_ the Signal 11 Software hidapi!

Mike.

On 13 October 2014 17:15, <al...@4z5lv.net> wrote:
Leif,

Please think about use of HIDAPI (from signal11) - I provided the link to you and forget about thinking how to rename /dev/hidraw
It is very easy to use/add HIDAPI to any project.
 If FunCube uses HID device it will be good for FunCube too

73!
Alex

Mike Keehan

unread,
Oct 14, 2014, 6:17:14 AM10/14/14
to lin...@googlegroups.com
Hi Leif,

I think you need a different rule for a HID device, try the following :-

KERNEL=="hidraw*", ATTRS{busnum}=="1", ATTRS{idVendor}=="255d", ATTRS{idProduct}=="0006", MODE="0666"
KERNEL=="hidraw*", ATTRS{busnum}=="1", ATTRS{idVendor}=="255d", ATTRS{idProduct}=="0006", MODE="0662"

This is based on the corresponding rule that is needed for the Funcube.

Mike.

Mike Keehan

unread,
Oct 14, 2014, 11:36:03 AM10/14/14
to lin...@googlegroups.com
Typo - second line of rule should be -

KERNEL=="hidraw*", ATTRS{busnum}=="1", ATTRS{idVendor}=="255d", ATTRS{idProduct}=="0002", MODE="0666"

.

al...@4z5lv.net

unread,
Oct 14, 2014, 3:59:57 PM10/14/14
to lin...@googlegroups.com


On Tuesday, October 14, 2014 12:59:15 PM UTC+3, Mike Keehan wrote:
Hi Alex,

The Funcube code in Linrad _is_ the Signal 11 Software hidapi!

Mike.


Mike,
On all available to me PCs  HIDAPI Signal11 perfectly working with config I posted above.
 
In addition If user uses only one SDR why he should be bothered by Serial Number?
Serial Number when application opens device good when there is multiple SDR instances connected to same PC.
HIDAPI allow sto open device without any serial umber - user simply must provide NULL pointer instead Serail Number's string.

I.e. in function:
hid_open(HID_DEVICE_VID, HID_DEVICE_PID, SerialNumber);
when:
SerialNumber = NULL;

HID device will be perfectly opened without it (serial number).

73!
Alex

Leif Asbrink

unread,
Oct 15, 2014, 7:19:32 PM10/15/14
to lin...@googlegroups.com
Hi Alex and Mike,

I have done some experimenting and found something that works.

The error message when a user does not have permissions now
looks like this:
[1393]Could not open the Afedri USB control interface.
You need permission to write to the USB HID device.
There are severalo choices:
1) You can run Linrad as root
2) Use chmod as root to change permissions for the device.
3) Create a udev rules file: ..../udev/rules.d/99-afedri.rules
SUBSYSTEM=="hidraw*", ATTRS{idVendor}=="255d",
ATTRS{idProduct}=="0002", MODE="0666"
SUBSYSTEM=="hidraw*", ATTRS{idVendor}=="0483",
ATTRS{idProduct}=="5932", MODE="0666"
SUBSYSTEM=="hidraw*", ATTRS{idVendor}=="255d",
ATTRS{idProduct}=="0001", MODE="0666"
SUBSYSTEM=="hidraw*", ATTRS{idVendor}=="255d",
ATTRS{idProduct}=="0006", MODE="0666"

> In addition If user uses only one SDR why he should be bothered by Serial
> Number?
> Serial Number when application opens device good when there is multiple SDR
> instances connected to same PC.
I have two Afedri units as you know:-)

When unplugging one and then plugging in the other I would
get errors that are non-trivial to detect.

> HIDAPI allow sto open device without any serial umber - user simply must
> provide NULL pointer instead Serail Number's string.

I do not understand why you think the serial number is a problem.
It is auto-selected if there is only a single Afedri device.

> I.e. in function:
> hid_open(HID_DEVICE_VID, HID_DEVICE_PID, SerialNumber);
> when:
> SerialNumber = NULL;
>
> HID device will be perfectly opened without it (serial number).
Yes, but why?

I have changed the error messages in the latest version on the
repo. The serial number message will now only appear when there
are Afedri devices but with non-matching serial numbers.

73

Leif

al...@4z5lv.net

unread,
Oct 16, 2014, 2:54:35 AM10/16/14
to lin...@googlegroups.com
Hello Leif,


On Thursday, October 16, 2014 2:19:32 AM UTC+3, SM5BSZ wrote:
Hi Alex and Mike,

I have done some experimenting and found something that works.

The error message when a user does not have permissions now
looks like this:

I will try the udev configuration later.
 
I have two Afedri units as you know:-)

When unplugging one and then plugging in the other I would
get errors that are non-trivial to detect.

Ok, I need to test this case with sdr_commander. very probably there is some problem.
 

I do not understand why you think the serial number is a problem.
It is auto-selected if there is only a single Afedri device.

Ok, Sorry I did not explained it before, as you know I have lot of AFEDRi in my stock :-)
So the prolem, that after first configuration - Linrad will accept only SDR that it was configured before, I will other unit - Linrad will deny to accept it - I need to make the
full configuration process from the beginning, despite that both units exactly same (only SN different). As you can suppose it is not convenient if I want to use Linrad for tests purposes...

.. The serial number message will now only appear when there
are Afedri devices but with non-matching serial numbers.


It is exactly the case I described above, so I have same the same question:
why user cannot replace one unit by second (that is exactly same, only has different serial number) without reconfiguration process (that takes some time as you know)?

73!
Alex

Leif Asbrink

unread,
Oct 16, 2014, 7:56:31 AM10/16/14
to lin...@googlegroups.com
Hi Alex,

> > When unplugging one and then plugging in the other I would
> > get errors that are non-trivial to detect.
> >
Problem found. I have to wait long enough for the Afedri to
boot up.......

> > I do not understand why you think the serial number is a problem.
> > It is auto-selected if there is only a single Afedri device.
> >
> > Ok, Sorry I did not explained it before, as you know I have lot of AFEDRi
> in my stock :-)
> So the prolem, that after first configuration - Linrad will accept only SDR
> that it was configured before, I will other unit - Linrad will deny to
> accept it - I need to make the
> full configuration process from the beginning, despite that both units
> exactly same (only SN different). As you can suppose it is not convenient
> if I want to use Linrad for tests purposes...
Oooh! Sure I understand.

At the bottom of options.h you now find:
// Disable the test for a serial number in Afedri.
//#define DISABLE_AFEDRI_SERIAL_NUMBER TRUE
#define DISABLE_AFEDRI_SERIAL_NUMBER FALSE

I hope you will find you can run one unit,
then press 'X', unplug and plug in the next unit.
Wait long enough for it to boot, then press 'B'.

I can not do that here because mine are two different types.

73

Leif

Dom DEHAYS

unread,
Nov 2, 2014, 5:48:29 AM11/2/14
to lin...@googlegroups.com
Hello ,
 
is there a driver for the ANAN-10 to use it under Linrad?
 
73
Dom

Leif Asbrink

unread,
Nov 2, 2014, 10:45:40 AM11/2/14
to lin...@googlegroups.com
Hello Dom,

This page has a link to a ExtIO dll for Hermes.
http://www.hdsdr.de/hardware.html

The link does not work, but you can probably find the dll
somewhere on the Internet.

Linrad should work with ExtIO dll files - but as far as I
know nobody has run the Hermes dll in Linrad yet.

73

Leif

Dom DEHAYS

unread,
Nov 2, 2014, 10:53:07 AM11/2/14
to lin...@googlegroups.com
Tnx info Leif ,

I have not yet decide wether I go ANAN10 or Hermes and if I go Hermes , it
is possible to do homebrew it , must think abt it

73
Dom

Roger Rehr

unread,
Nov 2, 2014, 1:19:14 PM11/2/14
to lin...@googlegroups.com
I am not sure that a working ExtIO.dll for Hermes actually exists.
My memory is that Alberto, I2PHD did an ExtIO.dll for Ozy/Mercury, but
I am not sure that he ever produced a working ExtIO.dll for Hermes.

Alberto is a member of this list, so perhaps he will comment :)

73,

Roger
W3SZ

Pierre

unread,
Nov 4, 2014, 12:37:51 PM11/4/14
to lin...@googlegroups.com
The source code and compilation instructions for the Extio.dll for
Hermes by Andrea Montefusco can be found at
https://github.com/amontefusco/extio-hermes

73,

Pierre / ON5GN

Roger Rehr

unread,
Nov 4, 2014, 12:40:23 PM11/4/14
to lin...@googlegroups.com
Thanks Pierre!
Reply all
Reply to author
Forward
0 new messages