Radio Amateur and Asterisk (chan_alsaradio.c part 3)

Practical details:

There are some things you need to tweak in order to make app_rpt and alsaradio working as a repeater and Echolink node.

Hardware:

I’m using FT-857D to build the repeater. The connection between PC and radio station is signaling and audio. For signaling I’m using the DATA connector on the back which is a mini DIN 6 pin:


The PTT is activated low and needs very low current to be activated. I measured about 140uA needed current for activating PTT.

The SQL signal (which sometimes is called CORCarrier Operated Relay or COSCarrier Operated Squelch) is activated high but it can only drive small current (uA) and therefore a transistor needs to be used to drive the serial line. That is why one will need an additional power supply if driving optocoupler is needed in an isolated interface (I’ll present it later on).

You could see that the DATA connector has DATA IN, DATA OUT 1200 and DATA OUT 9600 pins which could be used to input/output audio when no digital modes are used. However, DATA OUT pins do not output squelched audio. Hence I used only DATA IN for audio input and oudio output has been taken from oudio output jack in the back of the rig.

Audio adjustments:

A good level meter for ALSA is ameter. It is an ALSA plugin that will get the PCM level to from sound card and display it in a graphical environment. Download, build and install it as per given instructions.  The following is an screenshot of ameter GUI:

To adjust input level just use arecord with the following command:

arecord -D ameter -c 2 -f S16_LE test.waw

It will record the input level while showing ameter levels. You should adjust input level either from your card controls or from your rig’s volume level to see a 3/4 from your maximum ameter level.

To adjust output level you need to set your rig to display modulation level. Then adjust your card output level so that the modulation level is what your rig’s manual says (On FT-857 you should see couple of bars at maximum).

Testing the system:

If you start asterisk and signaling and media path are connected then you should be able to do the following from another radio station with a DTMF pad:

– activate parrot mode (simplex repeater functionality): *94 – now all you speak is sent back to you

– deactivate parrot mode: *95

– get system time: *81

– get version of the system: *82

– *3 – conects to an internet node (needs parrot mode disabled)

– *1 – disconnects from an internet node

All of the above DTMF sequences are configured in the rpt.conf and you coud add more, see app_rpt documentation.

Connecting to Echolink:

The Echolink numbers are prefixed with digit 3 and padded with 0 until 7 digits.

– *33009999 – this will conect to *ECHOTEST* node

– *13009999 – will disconnect from *ECHOTEST* node

Connecting to Allstarlink:

The Allstarlink numbers are starting by default with digit 2 and there is no need to prefix anything:

– *31234 conencts to Allstarlink number 1234

– *11234 disconnects from the Allstarlink number 1234

Connecting to IRLP:

The IRLP node numbers are prefixed with digit 4 and no padding.

– *349500 – connects to IRLP node 9500

– *149500 – disconnects from IRLP node 9500

Testing from Asterisk’s CLI:

DTMF commands could also be sent from the asterisk’s console. Start asterisk CLI with “asterisk -r” and then you should be able to do the same, for example:

rpt fun *94 – activate parrot mode

rpt fun *95 – deactivate parrot mode

Other commands useful for testing from CLI:

database show – shows database with Echolink nodes

aradio key – keys the transmitter

aradio unkey – unkeys the transmitter

aradio rkey – simulates COR present

aradio runkey – seize COR present

Sourcecode released as Open Source under GNU GPL license:

example of alsaradio.conf: alsaradio.conf.tar.gz

example of rpt.conf: rpt.conf.tar.gz

chan alsaradio (v01): chan_alsaradio.c_01.tar.gz

chan alsaradio (v02): chan_alsaradio.c_02.tar.gz

To correctly build the chan_alsaradio driver, the following line needs to be added in channels/Makefile:

chan_alsaradio.so: LIBS+=-lasound

10 thoughts on “Radio Amateur and Asterisk (chan_alsaradio.c part 3)

  1. I need some help. when I compile this I get this error

    chan_alsaradio.c: In function âalsaradio_readâ:
    chan_alsaradio.c:1298: warning: unused variable ânâ
    chan_alsaradio.c: At top level:
    chan_alsaradio.c:1859: warning: âtune_writeâ defined but not used
    chan_alsaradio.c:568: warning: âlpassâ defined but not used
    chan_alsaradio.c:606: warning: âsetamixerâ defined but not used
    how can I fix it? I would love to run this chan. just need to fix this.

  2. I have this loaded. and it keeps rebooting asterisk. In the log file I get this.
    [Feb 20 22:04:53] WARNING[6623] chan_alsaradio.c: alsaradio_request type data 0x0xb78aadbe
    Then asterisk reboots. I can see the asterisk is controling the soundcard and the serial port. But have no idea what i am doing wrong. Would you be willing to help he fix this?

    73
    Ryan
    KB8PMY

  3. Hi Ryan,

    I added the last version of chan_alsaradio.c I have to this thread. Also a version of alsaradio.conf I’m currently using.

    Regards,
    Bogdan

  4. There was a problem with the web server and the archives were damaged. Now they should be fixed. Mozilla seems to keep in cache the older versions of archives so probably is better to get them with wget. Also I added rpt.conf and alsaradio.conf I’m using.

  5. [CC] chan_alsaradio.c -> chan_alsaradio.o
    chan_alsaradio.c:94:18: error: busy.h: No such file or directory
    chan_alsaradio.c:95:22: error: ringtone.h: No such file or directory
    chan_alsaradio.c:96:20: error: ring10.h: No such file or directory
    chan_alsaradio.c:97:20: error: answer.h: No such file or directory
    chan_alsaradio.c:322: error: ‘ringtone’ undeclared here (not in a function)
    chan_alsaradio.c:323: error: ‘busy’ undeclared here (not in a function)
    chan_alsaradio.c:325: error: ‘ring10’ undeclared here (not in a function)
    chan_alsaradio.c:326: error: ‘answer’ undeclared here (not in a function)
    chan_alsaradio.c:557: warning: initialization from incompatible pointer type
    chan_alsaradio.c:726:31: error: macro “ast_config_load” requires 2 arguments, but only 1 given
    chan_alsaradio.c: In function ‘serthread’:
    chan_alsaradio.c:726: error: ‘ast_config_load’ undeclared (first use in this function)
    chan_alsaradio.c:726: error: (Each undeclared identifier is reported only once
    chan_alsaradio.c:726: error: for each function it appears in.)
    chan_alsaradio.c:726: warning: assignment from incompatible pointer type
    chan_alsaradio.c:753: warning: passing argument 2 of ‘ast_select’ from incompatible pointer type
    /root/Documents/PBX/asterisk/files/asterisk-1.8.4/include/asterisk/select.h:76: note: expected ‘struct ast_fdset *’ but argument is of type ‘struct fd_set *’
    chan_alsaradio.c:836:4: error: invalid suffix “x__dont_use_bcopy__use_memmove_instead” on integer constant
    chan_alsaradio.c: In function ‘send_sound’:
    chan_alsaradio.c:836: error: called object ‘’ is not a function
    chan_alsaradio.c:836: error: called object ‘’ is not a function
    chan_alsaradio.c:836: warning: statement with no effect
    chan_alsaradio.c:846:5: error: invalid suffix “x__dont_use_bcopy__use_memmove_instead” on integer constant
    chan_alsaradio.c:846: error: called object ‘’ is not a function
    chan_alsaradio.c:846: error: called object ‘’ is not a function
    chan_alsaradio.c:846: warning: statement with no effect
    chan_alsaradio.c:853:7: error: invalid suffix “x__dont_use_bcopy__use_memmove_instead” on integer constant
    chan_alsaradio.c:853: error: called object ‘’ is not a function
    chan_alsaradio.c:853: error: called object ‘’ is not a function
    chan_alsaradio.c:853: warning: statement with no effect
    chan_alsaradio.c:861: error: incompatible types when assigning to type ‘union ast_frame_subclass’ from type ‘long long unsigned int’
    chan_alsaradio.c:861: warning: statement with no effect
    chan_alsaradio.c:864: error: incompatible types when assigning to type ‘union ’ from type ‘short int *’
    chan_alsaradio.c:864: warning: statement with no effect
    chan_alsaradio.c: In function ‘sound_thread’:
    chan_alsaradio.c:899: warning: passing argument 2 of ‘ast_select’ from incompatible pointer type
    /root/Documents/PBX/asterisk/files/asterisk-1.8.4/include/asterisk/select.h:76: note: expected ‘struct ast_fdset *’ but argument is of type ‘struct fd_set *’
    chan_alsaradio.c:899: warning: passing argument 3 of ‘ast_select’ from incompatible pointer type
    /root/Documents/PBX/asterisk/files/asterisk-1.8.4/include/asterisk/select.h:76: note: expected ‘struct ast_fdset *’ but argument is of type ‘struct fd_set *’
    chan_alsaradio.c: In function ‘alsa_write’:
    chan_alsaradio.c:1131: error: incompatible type for argument 2 of ‘memcpy’
    /usr/include/string.h:43: note: expected ‘const void * __restrict__’ but argument is of type ‘union ’
    chan_alsaradio.c:1131: warning: statement with no effect
    chan_alsaradio.c: In function ‘alsaradio_write’:
    chan_alsaradio.c:1201: error: cannot convert to a pointer type
    chan_alsaradio.c:1178: warning: unused variable ‘tv2’
    chan_alsaradio.c:1177: warning: unused variable ‘tv’
    chan_alsaradio.c:1176: warning: unused variable ‘ret’
    chan_alsaradio.c:1175: warning: unused variable ‘ftmp’
    chan_alsaradio.c:1174: warning: unused variable ‘buftmp’
    chan_alsaradio.c: In function ‘alsa_read’:
    chan_alsaradio.c:1268: error: incompatible types when assigning to type ‘union ast_frame_subclass’ from type ‘int’
    chan_alsaradio.c:1268: warning: statement with no effect
    chan_alsaradio.c:1271: error: incompatible types when assigning to type ‘union ’ from type ‘void *’
    chan_alsaradio.c:1271: warning: statement with no effect
    chan_alsaradio.c:1307: error: incompatible types when assigning to type ‘union ast_frame_subclass’ from type ‘long long unsigned int’
    chan_alsaradio.c:1307: warning: statement with no effect
    chan_alsaradio.c:1310: error: incompatible types when assigning to type ‘union ’ from type ‘short int *’
    chan_alsaradio.c:1310: warning: statement with no effect
    chan_alsaradio.c: In function ‘alsaradio_read’:
    chan_alsaradio.c:1359: error: incompatible type for argument 1 of ‘fwrite’
    /usr/include/stdio.h:688: note: expected ‘const void * __restrict__’ but argument is of type ‘union ’
    chan_alsaradio.c:1359: warning: statement with no effect
    chan_alsaradio.c:1382: error: incompatible types when assigning to type ‘union ast_frame_subclass’ from type ‘int’
    chan_alsaradio.c:1382: warning: statement with no effect
    chan_alsaradio.c:1388: error: incompatible types when assigning to type ‘union ast_frame_subclass’ from type ‘int’
    chan_alsaradio.c:1388: warning: statement with no effect
    chan_alsaradio.c:1401: error: invalid operands to binary == (have ‘union ast_frame_subclass’ and ‘int’)
    chan_alsaradio.c:1401: error: invalid operands to binary == (have ‘union ast_frame_subclass’ and ‘int’)
    chan_alsaradio.c:1404: error: incompatible types when assigning to type ‘union ast_frame_subclass’ from type ‘int’
    chan_alsaradio.c:1404: warning: statement with no effect
    chan_alsaradio.c:1408: warning: format ‘%c’ expects type ‘int’, but argument 6 has type ‘union ast_frame_subclass’
    chan_alsaradio.c:1414: error: cannot convert to a pointer type
    chan_alsaradio.c: In function ‘alsaradio_new’:
    chan_alsaradio.c:1541: warning: passing argument 9 of ‘__ast_channel_alloc’ makes integer from pointer without a cast
    /root/Documents/PBX/asterisk/files/asterisk-1.8.4/include/asterisk/channel.h:1108: note: expected ‘int’ but argument is of type ‘char *’
    chan_alsaradio.c:1557: error: ‘struct ast_channel’ has no member named ‘cid’
    chan_alsaradio.c:1557: error: request for member ‘cid_num’ in something not a structure or union
    chan_alsaradio.c:1557: warning: statement with no effect
    chan_alsaradio.c:1558: error: ‘struct ast_channel’ has no member named ‘cid’
    chan_alsaradio.c:1558: error: request for member ‘cid_ani’ in something not a structure or union
    chan_alsaradio.c:1558: warning: statement with no effect
    chan_alsaradio.c:1559: error: ‘struct ast_channel’ has no member named ‘cid’
    chan_alsaradio.c:1559: error: request for member ‘cid_name’ in something not a structure or union
    chan_alsaradio.c:1559: warning: statement with no effect
    chan_alsaradio.c:1561: error: ‘struct ast_channel’ has no member named ‘cid’
    chan_alsaradio.c:1561: error: request for member ‘cid_dnid’ in something not a structure or union
    chan_alsaradio.c:1561: warning: statement with no effect
    chan_alsaradio.c: At top level:
    chan_alsaradio.c:1826: warning: initialization from incompatible pointer type
    chan_alsaradio.c:1827: warning: initialization makes integer from pointer without a cast
    chan_alsaradio.c:1827: error: initializer element is not computable at load time
    chan_alsaradio.c:1827: error: (near initialization for ‘cli_alsaradio[0].inuse’)
    chan_alsaradio.c:1830: warning: initialization from incompatible pointer type
    chan_alsaradio.c:1831: warning: initialization makes integer from pointer without a cast
    chan_alsaradio.c:1831: error: initializer element is not computable at load time
    chan_alsaradio.c:1831: error: (near initialization for ‘cli_alsaradio[1].inuse’)
    chan_alsaradio.c:1834: warning: initialization from incompatible pointer type
    chan_alsaradio.c:1835: warning: initialization makes integer from pointer without a cast
    chan_alsaradio.c:1835: error: initializer element is not computable at load time
    chan_alsaradio.c:1835: error: (near initialization for ‘cli_alsaradio[2].inuse’)
    chan_alsaradio.c:1838: warning: initialization from incompatible pointer type
    chan_alsaradio.c:1839: warning: initialization makes integer from pointer without a cast
    chan_alsaradio.c:1839: error: initializer element is not computable at load time
    chan_alsaradio.c:1839: error: (near initialization for ‘cli_alsaradio[3].inuse’)
    chan_alsaradio.c:1842: warning: initialization from incompatible pointer type
    chan_alsaradio.c:1843: warning: initialization makes integer from pointer without a cast
    chan_alsaradio.c:1843: error: initializer element is not computable at load time
    chan_alsaradio.c:1843: error: (near initialization for ‘cli_alsaradio[4].inuse’)
    chan_alsaradio.c:1846: warning: initialization from incompatible pointer type
    chan_alsaradio.c:1847: warning: initialization makes integer from pointer without a cast
    chan_alsaradio.c:1847: error: initializer element is not computable at load time
    chan_alsaradio.c:1847: error: (near initialization for ‘cli_alsaradio[5].inuse’)
    chan_alsaradio.c:1850: warning: initialization from incompatible pointer type
    chan_alsaradio.c:1851: warning: initialization makes integer from pointer without a cast
    chan_alsaradio.c:1851: error: initializer element is not computable at load time
    chan_alsaradio.c:1851: error: (near initialization for ‘cli_alsaradio[6].inuse’)
    chan_alsaradio.c:1854: warning: initialization from incompatible pointer type
    chan_alsaradio.c:1855: warning: initialization makes integer from pointer without a cast
    chan_alsaradio.c:1855: error: initializer element is not computable at load time
    chan_alsaradio.c:1855: error: (near initialization for ‘cli_alsaradio[7].inuse’)
    chan_alsaradio.c: In function ‘store_config’:
    chan_alsaradio.c:2009: error: ‘DSP_FEATURE_DTMF_DETECT’ undeclared (first use in this function)
    chan_alsaradio.c:2009: warning: passing argument 2 of ‘ast_dsp_set_features’ makes integer from pointer without a cast
    /root/Documents/PBX/asterisk/files/asterisk-1.8.4/include/asterisk/dsp.h:116: note: expected ‘int’ but argument is of type ‘struct ast_cli_entry *’
    chan_alsaradio.c:2010: warning: implicit declaration of function ‘ast_dsp_digitmode’
    chan_alsaradio.c:2458:36: error: macro “ast_config_load” requires 2 arguments, but only 1 given
    chan_alsaradio.c: In function ‘load_module’:
    chan_alsaradio.c:2458: error: ‘ast_config_load’ undeclared (first use in this function)
    chan_alsaradio.c:2458: warning: assignment from incompatible pointer type
    make[1]: *** [chan_alsaradio.o] Error 1
    make: *** [channels] Error 2

  6. Please find below the gdb backtrace output:

    (gdb) bt full
    #0 0x00000000 in ?? ()
    No symbol table info available.
    #1 0x003908ed in ___newselect_nocancel () from /lib/libc.so.6
    No symbol table info available.
    #2 0x004a9e76 in ast_select (arg=0x0) at /home/TASL/Installer/asterisk-1.8.11.1/include/asterisk/select.h:84
    No locals.
    #3 serthread (arg=0x0) at chan_alsaradio.c:748
    ctcssed =
    txreq =
    lastrx = 0 ’00’
    fname = “alsaradio_tune_ard0.conf”, ’00’ , “16\31062″, ’00’
    res =
    o = 0x0
    to = {tv_sec = 0, tv_usec = 0}
    cfg1 = 0x0
    v =
    rfds = {fds_bits = {0, 512, 0 }}
    zeroflag = {flags = 0}
    __PRETTY_FUNCTION__ = “serthread”
    #4 0x00000000 in ?? ()

    Please analyse and provide your valuable feedback so that I can use this driver with my asterisk server.

  7. Can alsa radio is working ?
    How to make radio to radio call.
    Thanks in advance , i am stuck here. Pls help.

  8. Somehow succesful in running rpt . But following error is coming again and again. Kindly help.
    *CLI> [Jul 27 11:24:29] NOTICE[2626]: app_rpt.c:13133 rpt_exec: parsing argument=102
    [Jul 27 11:24:29] NOTICE[2626]: app_rpt.c:13151 rpt_exec: options=(null)
    [Jul 27 11:24:29] NOTICE[2626]: app_rpt.c:1397 linkcount: numoflinks=0
    [Jul 27 11:24:29] WARNING[2626]: app_rpt.c:13274 rpt_exec: We only accept links via IAX2 or Local!!

    succesfully registered the node with sound card but don’t know how to bridge with local channel.

  9. Just to let you know, your chan_alsaradio works OK on a Raspberry PI with arch linux….

    regards

    Anthony, VK2ACP

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>