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

AMBE Server stops working #5

Open
dl1esz opened this issue May 17, 2019 · 7 comments
Open

AMBE Server stops working #5

dl1esz opened this issue May 17, 2019 · 7 comments

Comments

@dl1esz
Copy link

dl1esz commented May 17, 2019

AMBE Server on Raspberry Pi3 stops working
aktuall raspian AMBE device: AMBE3000 Hardware on Arduino Duo Software from DVMEGA
AMBEServer -d -p2461 compiled for 230400 Baud. Power option on Raspi ok no rttheling voltage ok.
When stops AMBEServer (maybe after hours, simulated by hig loads of cpu on rpi) following Error Messaege is seen
image
Serial payload exceeds buffer size:65332
processSerial failed to read packet

a new AMBEServer start brings it to work for a while.

If i use a DV30 USB AMBE Stick (460800 Baud) this issue is not given only by using AMBE3000 shild with arduino (230400Baud)
On Windows BlueDV Software connected to USB the Arduinoshild with AMBE3000 work fine without stoping.
Different RPI ( Pi zeroW, RPI2b) frsh installation and each fresh compiled comes to the same result

@lwkoon
Copy link

lwkoon commented May 22, 2019

I am also having some issue on the AMBEserver service is running but actually dying, running -x for now (debugging mode), the only way to solve is to restart the AMBEserver process.

a script of checking AMBE process won't help as the PID is still runing on linux (im running raspbian on rpi 3b+)

@pa7lim
Copy link

pa7lim commented May 22, 2019

The traffic to the AMBEServer is UDP so not reliable. If the packet is corrupted and the AMBEServer is receiving an AMBE packet length of e.g. 322 but the AMBE header is 65132 ( e.g. due bad internet) ( see crash report), the AMBEserver will crash.
The only way to fix this is by making a good check/parsing of the AMBE packet before sending it to the AMBE3000. This also prevents the lock up of the AMBE3000 due a bad internet connection.

@lwkoon
Copy link

lwkoon commented May 22, 2019

packet

I am not good at C language but i tot some checking of length payload check is there?

if (bytesRead != dv3k_packet_size(packet)) {
fprintf(stderr, "AMBEserver: invalid length when reading from the socket, %zd=%zd", bytesRead, dv3k_packet_size(packet));
return 1;
}

@dl1esz
Copy link
Author

dl1esz commented May 22, 2019 via email

@marrold
Copy link
Owner

marrold commented May 27, 2019

Hi all, apologies I seem to have missed this thread. I am not so active with DMR now, my AMBE chips are in storage and I'm not very good at C!

@lwkoon can you create a fork with your suggested change and then test it to see if it resolves the issue?

Thanks

@lwkoon
Copy link

lwkoon commented Sep 20, 2019

After glance through with my limited knowledge of C++ from the code:-

the return of the checking of processSocket() should be return 0 instead of 1 after checking
maybe i try to put return 0 of function packet.start_byte != DV3K_START_BYTE and bytesRead != dv3k_packet_size(packet) and recompile and see how it goes

int processSocket(int sockFd, int serialFd)
{
socklen_t addrLen = sizeof(struct sockaddr_in);
ssize_t bytesRead;
struct dv3k_packet packet;

bytesRead = recvfrom(sockFd, &packet, sizeof(packet), 0, (struct sockaddr *) &sa, &addrLen);
if (bytesRead < 0) {
    fprintf(stderr, "AMBEserver: error when reading from the socket: %s\n", strerror(errno));
    return 0;
}

if (packet.start_byte != DV3K_START_BYTE) {
    fprintf(stderr, "AMBEserver: invalid start byte when reading from the socket, 0x%02X", packet.start_byte);
    return 0;
}

if (bytesRead != dv3k_packet_size(packet)) {
    fprintf(stderr, "AMBEserver: invalid length when reading from the socket, %zd=%zd", bytesRead, dv3k_packet_size(packet));
    return 0;
}

if (debug)
    dump("Socket data", &packet);

if (write(serialFd, &packet, dv3k_packet_size(packet)) != dv3k_packet_size(packet)) {
    fprintf(stderr, "AMBEserver: error when writing to the serial port: %s\n", strerror(errno));
    return 0;
}

return 1;

}

@lwkoon
Copy link

lwkoon commented Aug 11, 2020

solved:
edit /boot/config.txt

Add
init_uart_clock=50000000

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

No branches or pull requests

4 participants