Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add support for DVSI AMBE3000 hardware codec devices #376

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

sm0svx
Copy link
Owner

@sm0svx sm0svx commented Mar 1, 2018

No description provided.

Not fully functional yet. For example:
- It only work with 8kHz audio at the moment
- Error handling need to be improved
- Serial protocol synchronization need to be done on startup
- Add more code documentation
- Rename CodecVector type to Codecs
- Use std::copy instead of for loop
- Return AudioEncoderAmbe/AudioDecoderAmbe instead of AudioCodecAmbe
  objects when allocating encoders/decoders
- Correct setup of fileds length indicator in the multi field Packet
  constructor
@sm0svx sm0svx mentioned this pull request Mar 1, 2018
@sm0svx sm0svx changed the title Add support for DVSI AMBE3000 hardware codec devices WIP: Add support for DVSI AMBE3000 hardware codec devices Mar 1, 2018
@dl1hrc
Copy link
Contributor

dl1hrc commented Mar 4, 2018

Set up a simple svxlink<->remotetrx environment with ThumbDV (two sticks, one on SvxLink site the other on remotetrx site). Got the following error message on remotetrx:
NetUplinkTrx: Client connected: 192.168.178.45:33043

Program received signal SIGSEGV, Segmentation fault.
0x0812d5bc in NetUplink::handleIncomingConnection (this=0x8241a90, incoming_con=0x8253330)
at /home/adi/svxlink-sm0svx/src/svxlink/remotetrx/NetUplink.cpp:285
285 audio_dec->release();
(gdb) quit
A debugging session is active.

Inferior 1 [process 6185] will be killed.

SvxLink v1.6.99.9
RemoteTrx v1.2.99.2

@sm0svx
Copy link
Owner Author

sm0svx commented Mar 4, 2018

Try now

@sm0svx sm0svx self-assigned this Mar 4, 2018
@dl1hrc
Copy link
Contributor

dl1hrc commented Mar 5, 2018

very well done, Tobias :)

@dl1hrc
Copy link
Contributor

dl1hrc commented Mar 6, 2018

Maybe there is a new (or recent) problem with RemoteTRX. I've configured a Voter and a MultiTX on SvxLink and a RemoteTRX with VOX. Here is the RemoteTRX's logfile:

Tue Mar 6 08:02:44 2018: RemoteTrx v1.2.99.2 Copyright (C) 2003-2015 Tobias Blomberg / SM0SVX
Tue Mar 6 08:02:44 2018:
Tue Mar 6 08:02:44 2018: RemoteTrx comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
Tue Mar 6 08:02:44 2018: welcome to redistribute it in accordance with the terms and conditions in the
Tue Mar 6 08:02:44 2018: GNU GPL (General Public License) version 2 or later.
Tue Mar 6 08:02:44 2018:
Tue Mar 6 08:02:44 2018: Using configuration file: /etc/svxlink/remotetrx.conf
Tue Mar 6 08:02:44 2018: --- Using sample rate 48000Hz
Tue Mar 6 08:02:44 2018: Setting up trx "NetUplinkTrx"
Tue Mar 6 08:02:44 2018: RX: Rx1
Tue Mar 6 08:02:44 2018: TX: Tx1
Tue Mar 6 08:02:44 2018:
Tue Mar 6 08:03:02 2018: NetUplinkTrx: Client connected: 192.168.178.45:44027
Tue Mar 6 08:03:02 2018: Rx1: SetMuteState(NONE)
Tue Mar 6 08:03:02 2018: NetUplinkTrx: Using CODEC "AMBE" to encode RX audio
Tue Mar 6 08:03:02 2018: NetUplinkTrx: Using CODEC "AMBE" to decode TX audio
Tue Mar 6 08:03:02 2018: --- DV3K: Reset OK
Tue Mar 6 08:03:02 2018: --- DV3K (ProdID): AMBE3000R--- DV3K (VersID): V120.E100.XXXX.C106.G514.R009.B0010411.C0020208--- DV3K: Ready
Tue Mar 6 08:03:13 2018: Rx1: The squelch is OPEN (6.63163)
Tue Mar 6 08:03:13 2018: Rx1: SetMuteState(NONE)
Tue Mar 6 08:03:14 2018: Tx1: Turning the transmitter ON
Tue Mar 6 08:03:19 2018: Rx1: The squelch is CLOSED (5.63445)

....
the tx remains on!
And the SvxLink's logfile:

06.03.2018 08:03:02.751: 192.168.178.57:5400: RemoteTrx protocol version 2.7
06.03.2018 08:03:02.753: NetDmrRx: Connected to remote receiver at 192.168.178.57:5400
06.03.2018 08:03:02.753: NetDmrRx: Requesting CODEC "AMBE"
06.03.2018 08:03:02.753: NetDmrTx: Connected to remote transmitter at 192.168.178.57:5400
06.03.2018 08:03:02.753: NetDmrTx: Requesting CODEC "AMBE"
06.03.2018 08:03:13.858: Voter: The squelch is OPEN (NetDmrRx=6.38163)
06.03.2018 08:03:50.028: NetDmrRx: Disconnected from remote receiver 192.168.178.57:5400: Connection closed by remote peer
06.03.2018 08:03:50.028: NetDmrTx: Disconnected from remote transmitter at 192.168.178.57:5400: Connection closed by remote peer

06.03.2018 08:03:50.029: Voter: The squelch is CLOSED (NetDmrRx=5.68417)

....

As you can see, there is no "Tx1: Turning the transmitter ON" when the TX is going on and no "The squelch is CLOSED (NetDmrRx=xxx)" on SvxLink site when the SQL has been closed on RemoteTRX's site so the Tx on SvxLink's site remains on. The bold text shows the stop of remotetrx (with kill -9), after that the SQL was closing on SvxLink and it continues the normal behavior.

@sm0svx
Copy link
Owner Author

sm0svx commented Mar 6, 2018

Probably some problem with the flow control in the audio pipe. Does it work if you change to another codec?

@dl1hrc
Copy link
Contributor

dl1hrc commented Mar 6, 2018

With the same config S16, OPUS and GSM seem to be ok. On SvxLink the log messages are normal (with TX is ON/OFF):
Voter: The squelch is OPEN (NetDmrRx=1.35875)
MultiTx: Turning the transmitter ON
NetDmrTx: The transmitter is ON
Voter: The squelch is CLOSED (NetDmrRx=5.74593)
Voter: The squelch is OPEN (NetDmrRx=5.50787)
Voter: The squelch is CLOSED (NetDmrRx=5.68277)
NetDmrTx: The transmitter is OFF
MultiTx: Turning the transmitter OFF

@dl1hrc
Copy link
Contributor

dl1hrc commented Mar 6, 2018

BTW: Havn't changed the name of "NetDmrRx" to NetOpusRx or something like this, changed only the codec

@sm0svx
Copy link
Owner Author

sm0svx commented Mar 7, 2018

Ok. I'll have a look at it tomorrow.

@sm0svx
Copy link
Owner Author

sm0svx commented Mar 8, 2018

It should work better now

@dl1hrc
Copy link
Contributor

dl1hrc commented Mar 10, 2018

unfortunately no. Some less audio is transmitting but then the SQL remains open as well as the PTT.

The first try create a segfault (could not reproduce it later):
NetUplinkTrx: Using CODEC "AMBE" to decode TX audio
--- DV3K: Reset OK
--- DV3K (ProdID): AMBE3000R
--- DV3K (VersID): V120.E100.XXXX.C106.G514.R009.B0010411.C0020208
--- DV3K: Ready
Rx1: SetMuteState(CONTENT)
*** WARNING: Unknown DV3K packet type received: 255
*** WARNING: Unknown DV3K packet type received: 255
*** WARNING: Unknown DV3K packet type received: 158
remotetrx: /home/adi/svxlink-sm0svx/src/async/audio/AsyncAudioCodecAmbe.cpp:555: void {anonymous}::AudioCodecAmbeDv3k::handlePacket(): Assertion `m_outstanding_enc_packets > 0' failed.
Abgebrochen (Speicherabzug geschrieben)
root@adi-Aspire-5733Z:~# remotetrx

@sm0svx
Copy link
Owner Author

sm0svx commented Mar 11, 2018

Looks like communications with the DV3k dongle is getting out of synch, which is very strange. I've had my remotetrx running with an example config here (attached remotetrx-dv3k-test.conf.txt) for several days without a single problem. Please try that to see if you get the same error as with your own config.

Handling communication failures with the dongle gracefully is still on the TODO-list so if communications is getting out of synch a failure like the one above is to be expected. I'd expect failures to be rare though but your setup seem to fail immediately which is very odd.

From your screen dump it looks like you are running this on a normal intel based laptop. Is that so?

@dl1hrc
Copy link
Contributor

dl1hrc commented Mar 11, 2018

Ahh, ok. I think I found my mistake. I was running it as a fullduplex remotetrx connected to my repeater. Will try it in a simplex environment.
Hardware are a normal Laptop and a mini-itx board, both intel based

@dl1hrc
Copy link
Contributor

dl1hrc commented Mar 11, 2018

ok, with one RX it's working :)

@sm0svx
Copy link
Owner Author

sm0svx commented Mar 24, 2018

Ok, that's good but don't you think your first setup should work as well? You should be able to set up a NetTrx with one transmitter and one receiver and then use one codec dongle to handle both streams. The receiver is using the encoder part and the transmitter is using the decoder part.

If this does not work there still is a bug in my code, right?

@dl1hrc
Copy link
Contributor

dl1hrc commented Mar 24, 2018

I'm not sure what the problem is right now. Will set up it tomorrow again.
Is there a possible problem if you send a pcm audio stream to the dv-device while receiving decoded audio from the dv-device without delay? With all other codecs you have two distinct instances (encoder/decoder) so the *coder should not being influenced by the other. But in a duplex remoteTrx thumbDV-environment where both streams accessing the same hardware device you receive a signal on NetRx, encode it there, sends them to the SvxLink node and get back the almost same encoded stuff (decode then encode it again on main node) from the SvxLink-node for the NetTx with only a small latency....

@sm0svx
Copy link
Owner Author

sm0svx commented Mar 24, 2018

It should not be a problem since SvxLink is single threaded. The two uses should not interfere with each other but it certainly looks like it does that anyway. As long as there is only one SvxLink/RemoteTrx process accessing the dongle it should be fine. In theory...

@dl1hrc
Copy link
Contributor

dl1hrc commented Mar 25, 2018

OK, I've finally setup a new remotetrx and it's working :) Maybe that some old files/libs have influenced my installation. There is one issue if the thumbdv stick couldn't open:
_Using configuration file: /etc/svxlink/remotetrx.conf
--- Using sample rate 48000Hz
Setting up trx "NetUplinkTrx"
RX: Rx1
TX: Tx1

NetUplinkTrx: Client connected: 192.168.178.45:56336
Rx1: SetMuteState(NONE)
*** ERROR: Can not open serial device /dev/ttyUSB0
*** ERROR: Could not initialize AMBE codec

Program received signal SIGSEGV, Segmentation fault.
0xb7e2ab05 in Async::Serial::close (this=0x0)
at /home/adi/svxlink-sm0svx/src/async/core/AsyncSerial.cpp:345
345 if (dev == 0)
(gdb)_

BTW: The audio quality between the stations is much better than expected and in my opinion the qso:
analogue Rf->encoding to DMR-Codec->network->decoding to analogue->analogue Rf
sounds better than a "normal" dmr qso with my Hytera-stuff.

@sm0svx
Copy link
Owner Author

sm0svx commented Mar 25, 2018

That is good news! Interesting that you think audio quality is better than the real DMR stuff. It must be that the analogue audio path is not as good on your Hytera as it is on your other rigs. I guess it would not be as good if you have a weak signal in with a lot of noise. That would be hard work for the codec.

I'll have a look at the segfault. It looks like a simple problem. You should also expect other problems since I've only implemented the bare minimum for you to have something to develop against. There are still error handling and timeouts missing. My test application ran for three or four days before it lost communication synchronization with the dongle and the code cannot handle that at the moment.

@dl1hrc
Copy link
Contributor

dl1hrc commented Mar 25, 2018

I made my tests without Rf from the RemoteTRX side, only on side is a analgue repeater. If disturbances or noise are involved into the path the quality may decrease. But for the moment it's really great.

But I have still the problem we discussed last weeks (maybe AudioSelector but not sure):
The SQL isn't closing and the roger beep failed to appear after some transmissions and the Tx's are not switched off. In my opinion it has nothing to do with the thumbdv branch, it's a pending problem we discussed here #353
I occurs in a multi logic environment and here in a SvxLink<->remoteTrx environment as well
Couln't find the last version that was working, hope to have the time next days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants