Thank you for your reply, Marc! I'll try to answer your questions the best I can:
Do You get any warning messages when compiling?
I do get a few warnings when compiling the sources, but I'm not sure if they are related to the segmentation faults I get when the app crashes. They refer to ignored return values and potential data type mismatch in printf format string.
eriedl@eriedl-ubuntuvm:~/pab014share$ make
gcc -O -Wall -I. -o padec padec.c -lm
gcc -O -Wall -I. -o iFlow iFlow.c -lm
In file included from iFlow.c:5:0:
aprs485.h: In function ‘hub_dt’:
aprs485.h:128:7: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
write(hd,buf,2);
^
gcc -O -Wall -I. -o iPump iPump.c -lm
In file included from iPump.c:5:0:
aprs485.h: In function ‘hub_dt’:
aprs485.h:128:7: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
write(hd,buf,2);
^
gcc -O -Wall -I. -o iComII iComII.c -lm
In file included from iComII.c:7:0:
aprs485.h: In function ‘hub_dt’:
aprs485.h:128:7: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
write(hd,buf,2);
^
gcc -O -Wall -I. -o iPmon iPmon.c -lm
In file included from iPmon.c:5:0:
aprs485.h: In function ‘hub_dt’:
aprs485.h:128:7: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
write(hd,buf,2);
^
gcc -O -Wall -I. -o aprs485 aprs485.c -lm
aprs485.c: In function ‘srv_client’:
aprs485.c:301:4: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘long int’ [-Wformat=]
a += sprintf(a,"\ntab[%d]",t-gl.tabs);
^
aprs485.c: In function ‘main’:
aprs485.c:635:3: warning: field precision specifier ‘.*’ expects argument of type ‘int’, but argument 3 has type ‘long unsigned int’ [-Wformat=]
else sprintf(gl.bus,"%.*s",sizeof(gl.bus)-1,p);
^
aprs485.c: In function ‘slog_dump’:
aprs485.c:88:22: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
if (fd >= 0) write(fd,buf,p-buf);
^
aprs485.c:90:34: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
if (gl.dbug) *p++ = '\r', write(1,buf,p-buf);
What kind of message do you get when aprs485 crashes? (if any at all).
Have you tried running aprs485 with the "debug option" switch?
Yes, I did. Executing just aprs485 just prints the usage. So I'm guessing it is something when trying to access the serial port:
eriedl@eriedl-ubuntuvm:~/pab014share$ ./aprs485 -d /dev/ttyUSB0
hit <Escape> to exit...
Segmentation fault (core dumped)
Are you using the CH341 driver? Or the generic USB-serial driver? (which I'm pretty sure won't work).
Well, I tried to compile the sources from WCH, but they spew several errors. But then I found out that the H341 driver already comes with Ubuntu 14. I verified that the port is recognized and drivers are loaded when I plug it in:
eriedl@eriedl-ubuntuvm:~/pab014share$ lsusb
Bus 001 Device 002: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
eriedl@eriedl-ubuntuvm:~/pab014share$ dmesg | grep USB
[ 0.293237] ACPI: bus type USB registered
[ 0.545457] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[ 0.546187] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[ 0.547518] ohci-pci 0000:00:06.0: new USB bus registered, assigned bus number 1
[ 0.603640] usb usb1: New USB device found, idVendor=1d6b, idProduct=0001
[ 0.605335] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 0.607812] hub 1-0:1.0: USB hub found
[ 0.609514] uhci_hcd: USB Universal Host Controller Interface driver
[ 166.909930] usb 1-1: new full-speed USB device number 2 using ohci-pci
[ 167.213782] usb 1-1: New USB device found, idVendor=1a86, idProduct=7523
[ 167.213787] usb 1-1: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[ 167.213789] usb 1-1: Product: USB2.0-Serial
[ 167.231294] usbserial: USB Serial support registered for generic
[ 167.232509] usbserial: USB Serial support registered for ch341-uart
[ 167.286873] usb 1-1: ch341-uart converter now attached to ttyUSB0
Have you tried to "cat" to the tty hardware? Can you "cat" without it throwing an error?
Yes, I did. Ubuntu has a bug that would not add the current user the dialout group so you couldn't access any serial port. I worked around that by doing to the following to be able to write and read to the USB/Serial port /dev/ttyUSB0:
eriedl@eriedl-ubuntuvm:~/pab014share$ groups ${USER}
eriedl : eriedl adm cdrom sudo dip plugdev lpadmin sambashare
eriedl@eriedl-ubuntuvm:~/pab014share$ sudo gpasswd --add ${USER} dialout
Adding user eriedl to group dialout
eriedl@eriedl-ubuntuvm:~/pab014share$ sudo chmod a+rw /dev/ttyUSB0
eriedl@eriedl-ubuntuvm:~/pab014share$ echo "Hello" > /dev/ttyUSB0
eriedl@eriedl-ubuntuvm:~/pab014share$ read X < /dev/ttyUSB0
eriedl@eriedl-ubuntuvm:~/pab014share$ echo $X
<this is just an empty line>
Can you run aprs485 under gdb?
I've never use gdb before, but I'm going to read up on it.
My next step would have been to try to get this working with the SoftwareSerial library from Arduino. That is, sending the "Talk over the COM port" command, which seems to be the sequence "A5 00 60 10 04 01 ff 02 19" or starting with "A5 01...". If I can get the pump to talk over the COM port that's already a big step.