fix setting instance variable of ttyDUMMY - #4
Conversation
The variable was looking for /dev/ttyDUMMYWVC when it resides in /tmp/ttyDUMMYWVC. It was working with only one instance but a second instance would fail to be found.
|
looks to be a bit more involved than I first though. The first instance will find no count so $I ends up being -1 which is no good. Then I found that interceptty isn't even started before the first check for ttyWVCDUMMY and it's initialized after a comm failure so the whole setting and echoing of the virtual comm device should be after every call to interceptty. I can kill this pull request and create another if you'd like? |
|
I do not that think that would be correct - interceptty creates the virtual device in /dev/ttyWVCDUMMY grep searches for how many incidences it see and creates a virtual device based on that if it there then the script strips of the relevant data from that virtual device and then stores it in /tmp/ttyWVCDUMMY for secondary processing .. .. there should only one incidences of /dev/ WVCDUMMY unless you are running multiple copies of WVC which you do not need to do you enter all your inverters in the one config file . the script reads the config file and sends the request key for that inverter the corresponding inverter responds and replies and then that data is stored in /tmp/ttyWVCDUMMY.. if it only seeing the one inverter then it would seam the read function for the hc12 it not working for some reason.. but it works fine for my older version using HC12 or modem |
|
it was after I did not see any /dev/ttyWVC* devices in /dev which made me think it was looking in the wrong location. dlarue@mymachine:$ ps -efw | grep tty hmm, looks like it's creating the front-device in /dev/pts: |
|
hi there I looked through and tried it would seam you only need to change it to tty[W]VC, with out the if statement if nothing is running then it gets 0 as a result and if more then one is running it gets more of a count .. curious you do not get 0 as a result when you run in terminal with out wvc running |
|
The original code was looking for "[W]VC /dev" and it was never found no matter if interceptty was running or not. It always returned 0 so as long as you never tried to run two instances it worked fine. I felt that was broken since it always returned 0 so down the rabbit hole I went. LOL So since it's just naming the /tmp/ttyWVCDUMMY link as long as the returned value valid and different things are good. I tested by starting wvc new and not /tmp/ttyWVCDUMMYx link and it created /tmp/ttyWVCDUMMY0 Without the setting of "I" var and echoing after each opening of interceptty all you see is the first entry which runs before interceptty is run so it shows /tmp/ttyWVCDUMMY0 as the virtual port even when it's already open by another instance... example: I have another session editing /tmp/ttyWVCDUMMY0 so if you run "ps -efww | grep 'tty[W]VC' | wc -l" it will turn 1 but you see in the output below, it'll first say /tmp/ttyWVCDUMMY0 is the opened virtual port for this instance but when interceptty is really run, it will open /tmp/ttyWVCDUMMY1 and the added code setting variable "I" and the echo command shows what device really is being used. $ ./wvc /dev/ttyUSB0 ./wvc700-3.ini ff070618 hc | tee -a mosquitto.log Inverter Type WVC700 R3 no input from inverter 40000D02 no COM detected |
The variable was looking for /dev/ttyDUMMYWVC when it resides in /tmp/ttyDUMMYWVC. It was working with only one instance but a second instance would fail to be found.