-
Notifications
You must be signed in to change notification settings - Fork 147
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
[FR] Smart automation for correct port detection #287
Comments
bit out of scope of my code |
Sorry maybe stupid question but: Isn't more logical to have some "in start" code, mpp-solar -p /dev/hidraw1 -o raw -c QID#QPI#QMN#QVFW#QVFW2#QVFW3
Processing DEFAULT type responses
Command: QID - Device Serial Number inquiry
------------------------------------------------------------
raw_response '(553555355535552\xfd\r'
Processing DEFAULT type responses
Command: QPI - Protocol ID inquiry
------------------------------------------------------------
raw_response '(PI30\x9a\x0b\r'
Command: QMN - No description found <<<< Inverter Model
------------------------------------------------------------
raw_response "(VMIII-5000\xa8'\r"
Processing DEFAULT type responses
Command: QVFW - Main CPU firmware version inquiry
------------------------------------------------------------
raw_response '(VERFW:00091.20\xf8&\r'
Command: QVFW3 - No description found <<<< Bluetooth Firmware
------------------------------------------------------------
raw_response '(VERFW:00002.61\x17c\r' And if there is no problem with "Device Serial Number" aka 55355535553555 or device cloning This can be new functionality mpp-solar -detect-inverter with will display inverter hardware information and eventually suggest "install as service" |
Not really ideal to spam data at a serial port - if it's in use for other
things it could cause problems
The udev naming can use a script as well, or your script could just be a
startup script thay creates symlinks as necessary
The udev naming can also use the physical port as part of the selection
I am thinking of a similar comand to your suggestion to help with protocol
selection though
Maybe the refactored code could have a pre loop command for info gathering
that then selects which commands or setup is used
…On Sat, 24 Dec 2022, 10:04 pm Saentist, ***@***.***> wrote:
Sorry maybe stupid question but:
This will not work or even will destroy communication,
if there is more then one inverter connected to PC.
Just because inverters use same communication chip aka VID:PID.
Isn't more logical to have some "in start" code,
with to check all hidrawX/ttyUSBx with QID#QPI#QMN#QVFW#QVFW2#QVFW3 command
mpp-solar -p /dev/hidraw1 -o raw -c QID#QPI#QMN#QVFW#QVFW2#QVFW3
Processing DEFAULT type responses
Command: QID - Device Serial Number inquiry
------------------------------------------------------------
raw_response '(553555355535552\xfd\r'
Processing DEFAULT type responses
Command: QPI - Protocol ID inquiry
------------------------------------------------------------
raw_response '(PI30\x9a\x0b\r'
Command: QMN - No description found <<<< Inverter Model
------------------------------------------------------------
raw_response "(VMIII-5000\xa8'\r"
Processing DEFAULT type responses
Command: QVFW - Main CPU firmware version inquiry
------------------------------------------------------------
raw_response '(VERFW:00091.20\xf8&\r'
Command: QVFW3 - No description found <<<< Bluetooth Firmware
------------------------------------------------------------
raw_response '(VERFW:00002.61\x17c\r'
And if there is no problem with "Device Serial Number" aka 55355535553555
or device cloning
this information is enough to match "path to device"
------------------------------
This can be new functionality
mpp-solar -detect-inverter
with will display inverter hardware information and eventually suggest
"install as service"
—
Reply to this email directly, view it on GitHub
<#287 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJVKNWKYJPVZN3X2JWZEKDWO24DHANCNFSM6AAAAAATID6ZUY>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Still interested to see some automation in detection... import glob
import os
for f in glob.glob("/dev/hidraw*"):
with open(os.path.join("/sys/class/hidraw", os.path.basename(f), "device/uevent")) as uevent_file:
device_name = None
for line in uevent_file:
if line.startswith("HID_NAME="):
device_name = line[len("HID_NAME="):].strip()
break
print(f"{os.path.basename(f)}\t{device_name}") now I have this result
Question is how software to use automatically |
I still think this is the wrong approach - you are better to use udev rules (and base it off physical path if you have multiple) |
Problem i see is that hidraw arrange is different after any restart USB port have unique address in system, and can see what is attached there. |
but the cable is always in the same physical port, so you can use that in udev to create an unchanging symlink |
maybe I need to make video |
Yes hidraw will be random. But the actual physical port that the cable is
on is the same and you can write udev rules to create a new device based on
the physical port.
https://unix.stackexchange.com/questions/443250/udev-rule-to-alias-device-depending-on-usb-port-number
is an example (though it's not correct for your situation)
…On Thu, 8 Jun 2023, 5:15 pm Saentist, ***@***.***> wrote:
maybe I need to make video
same usb port
simple restart
Result hidraw are rearranged but APC is always hidraw0
hidraw1 and 2 are randomly assigned to Inverter and AIO PC Touchscreen
—
Reply to this email directly, view it on GitHub
<#287 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJVKNQXRAAKU23OOZOO7BTXKFNYZANCNFSM6AAAAAATID6ZUY>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I also prefer udev rules instead of any automation. With two same cables, I get the same VID:PID combinations. But with their serial numbers I can use rules.
But it doesn't seem to work. Though it points to the correct port, mpp-solar doesn't understand it:
But with the direct port it works:
So how do I have to use this? |
In the meantime I flew over your code and found some kind of filter check.
and works nice now:
So for me it's solved. But I let it here, maybe it's helpful for others. |
alternatively you need to tell it what type of port you are using, eg |
in powermon code |
On my PC there is a few USB devices which are HIDRAW(0-5)
but after restart they changed ordering.
If inverter was "hidraw1" next time is "hidraw5"
there is a simple bash script for detection
In my case result is:
How can make automatic hidraw detection and selection,
without hard selecting and avoid after restart non working results?
The text was updated successfully, but these errors were encountered: