This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Signal K Server v1.32.0 Released
#21
I have checked the signal k code and there is a blocking loop here: https://github.com/SignalK/signalk-serve...alk.js#L51 This could be the reason for that high process consumption.

Adding "time.sleep(0.01)" after line 51 should fix this but I am not sure where this file goes after installation to overwrite and test this change.
Reply
#22
(2020-08-12, 01:26 PM)monos1 Wrote: As MatsA commented, the input resistance is not sufficient and saturates the optocoupler emitter. I have to put a resistor in the Seatalk input to use the circuit I like.......

Thanks for the feedback.

(2020-08-12, 02:59 PM)glenn Wrote: The seatalk to $stalk parser strips the beginning 0.

So the 00  02  YZ  XX XX  Depth below transducer is translated to a single 0 instead of 00. Thus no depth input.

 Nice finding....Do You have a bug fix ?

(2020-08-12, 07:19 PM)Sailoog Wrote: I have checked the signal k code and there is a blocking loop here: https://github.com/SignalK/signalk-serve...alk.js#L51 This could be the reason for that high process consumption.

Adding "time.sleep(0.01)" after line 51 should fix this but I am not sure where this file goes after installation to overwrite and test this change.

Thanks for the feedback. The source is found at "/home/pi/signalk-server-node/packages/streams/pigpio-seatalk.js" in a standard SK install. Or just use  'sudo find / -name "pigpio-seatalk.js"' I don't have the possibility to check it for some days...
________________________________________

Blog; https://pysselilivet.blogspot.com/
Reply
#23
(2020-08-12, 09:19 PM)MatsA Wrote:
(2020-08-12, 07:19 PM)Sailoog Wrote: I have checked the signal k code and there is a blocking loop here: https://github.com/SignalK/signalk-serve...alk.js#L51 This could be the reason for that high process consumption.

Adding "time.sleep(0.01)" after line 51 should fix this but I am not sure where this file goes after installation to overwrite and test this change.

Thanks for the feedback. The source is found at "/home/pi/signalk-server-node/packages/streams/pigpio-seatalk.js" in a standard SK install. Or just use  'sudo find / -name "pigpio-seatalk.js"' I don't have the possibility to check it for some days...

I need to know where that embedded python code is installed to hardcode it and test this change because I do not want to build signal k server from source.
pigpio-seatalk.js is not found in a working system.
Reply
#24
I got it

I have no seatalk 1 so monos1 could you try this please?

You should edit this file:
/usr/lib/node_modules/signalk-server/node_modules/@signalk/streams/pigpio-seatalk.js
to add this change:
https://github.com/sailoog/signalk-serve...201c7e4d12

Restart signal k server after saving, test and check the CPU. You can play with this value: time.sleep(0.01), the higher value the better CPU performance but you should confirm you are not losing seatalk data.
Reply
#25
(2020-08-13, 11:54 AM)Sailoog Wrote: I need to know where that embedded python code is installed to hardcode it and test this change because I do not want to build signal k server from source.
pigpio-seatalk.js is not found in a working system.

I'm seeing it here, seatalk has been working on this machine 

pi@openplotter:~ $ sudo find / -name "pigpio-seatalk.js"
/usr/lib/node_modules/signalk-server/node_modules/@signalk/streams/pigpio-seatalk.js
find: ‘/run/user/1000/gvfs’: Permission denied
pi@openplotter:~ $ cat /usr/lib/node_modules/signalk-server/node_modules/@signalk/streams/pigpio-seatalk.js
/*
 *
 * prototype-server: An implementation of a Signal K server for boats.
 * Copyright © 2020 Teppo Kurki <teppo.kurki@iki.fi> *et al*.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * 2020-06-24 Original Python code from @Thomas-GeDaD https://github.com/Thomas-GeDaD/Seatalk1-Raspi-reader
 * and finetuned by @MatsA
 *
 */

const Execute = require('./execute')
const debug = require('debug')('signalkConfusedtreams:pigpio-seatalk')

const cmd = `
import pigpio, time, signal, sys

if  sys.argv[1] == "undefined":
        gpio = 4                                                                    #Default GPIO4 if not set
else:
        gpio = int(filter(str.isdigit, sys.argv[1]))    #Ggpio, info as "GPIOnn", from GUI setup. Sensing the seatalk1 (yellow wire)

if __name__ == "__main__":
        st1read =pigpio.pi()

        try:
                st1read.bb_serial_read_close(gpio) #close if already run
        except:
                pass

        st1read.bb_serial_read_open(gpio, 4800,9)

        if  sys.argv[2] == "true":                              # Invert, inverted input from ST1, selected in the GUI
                st1read.bb_serial_invert(gpio, 1)

        data=""

        try:
                while True:
                        out=(st1read.bb_serial_read(gpio))
                        out0=out[0]
                        if out0>0:
                                out_data=out[1]
                                x=0
                                while x < out0:
                                        if out_data[x+1] ==0:
                                                string1=str(hex(out_data[x]))
                                                data= data+string1[2:]+ ","
                                        else:
                                                data=data[0:-1]
                                                data="$STALK,"+data
                                                print (data)
                                                string2=str(hex(out_data[x]))
                                                data=string2[2:]+ ","
                                        x+=2
        except:
                st1read.bb_serial_read_close(gpio)
                print ("exit")
`

function PigpioSeatalk (options) {
  Execute.call(this, {debug})
  this.options = options
  this.options.command = `python -u -c '${cmd}' ${options.gpio} ${options.gpioInvert} `
}

require('util').inherits(PigpioSeatalk, Execute)


module.exports = PigpioSeatalk
pi@openplotter:~
Reply
#26
yes, sorry I was searching in a non updated system Smile
If someone with seatalk1 can test this change report please: https://forum.openmarine.net/showthread....8#pid15518
Reply
#27
(2020-08-13, 12:13 PM)Sailoog Wrote: I got it

I have no seatalk 1 so monos1 could you try this please?

You should edit this file:
/usr/lib/node_modules/signalk-server/node_modules/@signalk/streams/pigpio-seatalk.js
to add this change:
https://github.com/sailoog/signalk-serve...201c7e4d12

Restart signal k server after saving, test and check the CPU. You can play with this value: time.sleep(0.01), the higher value the better CPU performance but you should confirm you are not losing seatalk data.

Yes, it works

Now the cpu for pigpiod is always less than 10 %. 

Now just the lack of depth is the last issue.
Reply
#28
Great. Did you use 0.01 or something else?
Reply
#29
Just copy/paste time.sleep(0.01)
Reply
#30
OK, thanks a lot. Created a pull request and waiting for being approved: https://github.com/SignalK/signalk-serve.../pull/1096
I can not try to solve the depth issue without any seatalk 1 device but I am sure someone will do soon.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)