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

vcontrold error output #39

Closed
hmueller01 opened this issue Sep 13, 2018 · 3 comments
Closed

vcontrold error output #39

hmueller01 opened this issue Sep 13, 2018 · 3 comments

Comments

@hmueller01
Copy link
Collaborator

Currently I have a lot of communication problems with my vito. But this is another story.

I use vclient --host localhost --port 3002 -f vito-commands.txt -t vito-update.tmpl.py -x /dev/shm/vito-update.py to create a Python script with the data read from vito. If there is a communication error the corresponding value in vito-update.tmpl.py is replaced by e.g.

ERR: >FRAMER: could not close (3 attempts)
Error opening /dev/vitoir0

The problem is the line break which breaks execution of the Python script.
Because there are lots of data read out of vito it would be nice if the script runs despite the error. So it would be good if vcontrold does not output the error in that case (and leaves the value empty). I quickly tested this by setting errClass always to 99 in common.c::logIT(). But this should be done by a command line switch. Should I use an new switch like -q or should we use e.g. -vwhich is currently not really used (no error output to fd per default, only triggered by switch)?

Or is there another solution which I haven't seen?

@philverh
Copy link
Contributor

Preliminary note : I'm quite new working with the Vito protocols. I may have overseen the obvious. ;-)

I read through the code, and especially the IO.C my_send routine catched my eye. Before sending a byte to the device, the INPUT queue is purged twice before sending data to the OUTPUT.

  • The comment speaks about (around line 132) tcflush being unreliable, replacing it with a read call, then still calls tcflush of the input queue. One flush would be enough in my mind.
  • The code replacing the "failing" tcflush call uses direct fnctl calls to set and re-set non-blocking mode, while the person who wrote IO.C created functions to handle this. Wouldn't it be more coherent to use the functions defined in IO.C instead of direct fnctl calls.
  • Why blindly flushing the INPUT when trying to OUTPUT something? If some reply were received after sending the previous byte in a string, wouldn't it get purged by the following send? This obviously is timing dependent, both on the side of the Viessmann device and also on the device running vcontrold. In this case this would lead to data loss and mainly to protocol misses, requiring constant re-syncs.

Food for thought. I'll take some time to experiment.

@hmueller01
Copy link
Collaborator Author

@philverh You are right. It is strange why tcflush does not work. And I also think using the io.c functions for non-blocking mode is better.

At least in non P300 protocol the vitronic sends 0x05 periodic. This or other bytes might be in the input buffer, so it must be cleared before as we want only the answer to our request ...

But maybe the discussion about the implementation of io.c (and others) might be started in another issue as I like to know what command line option is best if we want to suppress the error output in the normal output. BTW: The errors are still written to syslog. So one can still see that there was something wrong.

@hmueller01
Copy link
Collaborator Author

I was thinking about my suggestion. Meanwhile I think it is better to modify vclient instead of changing the daemon. The issue is only on $Rn variables. What do you think about changing that code in vclient.c line 443 to

                            // if tPtr->raw starts with "ERR:" output only if verbose
                            if (!((verbose == 0) && strncmp(tPtr->raw, ERR, strlen(ERR)) == 0)) {
                                fprintf(ofilePtr, "%s", tPtr->raw);
                            }

So vclient without -v will suppress the output, while telnet or vclient with -v will still show the error.

hmueller01 added a commit to hmueller01/vcontrold that referenced this issue Oct 23, 2020
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

2 participants