September 12, 20169 yr Author 12 hours ago, Manie said: It will be deur mekaar because you have to wait for the string to complete then clear it before you call again. What i can see is that you get values back from the inverter while clearing the string. So you get half of the previous call. You out of sync. You have to wait until you get cr (13) (0D) then you know you are at the end and can clear the return string and send it again. No need for experts . Its just logic lol. Coding problem !!!. Fix the coding and you will recieved the complete string return. Sent from my SM-G920F using Tapatalk Thanx. what you're saying make a lot of sense. Now I just need to figure out how to achieve this in python.
September 12, 20169 yr 27 minutes ago, SilverNodashi said: Thanx. what you're saying make a lot of sense. Now I just need to figure out how to achieve this in python Are you not going to do it in C# ?
September 12, 20169 yr 57 minutes ago, Manie said: Are you not going to do it in C# ? I thought you're already using something non-pythony. Because I cannot see how you could get the result wrong if you write the query string and then literally read character for character until you hit the newline. Also, when I wrote my mk2 library, I found that sometimes flushing the buffer beforehand is also required. I don't know what the Axpert does, but with the mk2 it continuously spits out version frames. The computer side has a small buffer and it can buffer as much as a megabyte of unsolicited version responses... :-) So the first thing you have to do with the mk2 is send out some kind of throwaway message (I send a version request)... wait half a second, then clear the buffer. That way you know the line is clear. You can glean some ideas here if you want: https://github.com/izak/ib.victron Just, the mk2 protocol is not plain ascii, which is why I have to use struct pack()/unpack() all over the place. It also has a leading length byte in the protocol, so you don't have to read character by character once you know how much is coming.
September 12, 20169 yr I thought you're already using something non-pythony. Because I cannot see how you could get the result wrong if you write the query string and then literally read character for character until you hit the newline. Also, when I wrote my mk2 library, I found that sometimes flushing the buffer beforehand is also required. I don't know what the Axpert does, but with the mk2 it continuously spits out version frames. The computer side has a small buffer and it can buffer as much as a megabyte of unsolicited version responses... :-) So the first thing you have to do with the mk2 is send out some kind of throwaway message (I send a version request)... wait half a second, then clear the buffer. That way you know the line is clear. You can glean some ideas here if you want: https://github.com/izak/ib.victron Just, the mk2 protocol is not plain ascii, which is why I have to use struct pack()/unpack() all over the place. It also has a leading length byte in the protocol, so you don't have to read character by character once you know how much is coming. Yes we don't use python and we dont use any sleep function in the tread. If you use a sleep function its just guessing how long you need to sleep. However if you have to send 3 commands you can be out of sync and you wil get sometimes the wrong return Sent from my SM-G920F using Tapatalk
September 12, 20169 yr 7 minutes ago, Manie said: Yes we don't use python and we dont use any sleep function in the tread. If you use a sleep function its just guessing how low you need to sleep. However if you have to send 3 commands you can be out of sync and you wil get sometimes the wrong return Sent from my SM-G920F using Tapatalk Agreed, mostly. I use sleep literally only to sync in the beginning. After that it is full steam ahead. You can even send multiple commands and the responses will come back properly formed BUT... perhaps not in the same order you sent them. Some commands take longer to complete than others. The longest one I believe is 750ms, when multiple devices on vebus needs to be queried. But that's MK2. I have no idea about the Axpert. Basic principle remains though: Perhaps better to send one command at a time and wait until you have the full response. With firmware, where memory isn't plentiful, it is not uncommon to use a big blob of memory in a global variable for such things, in other words, it is not at all what we might call "thread safe" :-)
September 12, 20169 yr 7 minutes ago, TinkerBoy said: And the speed is one of the main reasons we are using USB and not Serial (RS-232). Possibly because USB devices typically have a bit more buffer memory. Remember the days of the 16550 UARTS where a missed interrupt was literally the end of the world? :-P
September 12, 20169 yr Author 6 hours ago, TinkerBoy said: And the speed is one of the main reasons we are using USB and not Serial (RS-232). Would you mind telling me how you got to communicate over USB?
September 12, 20169 yr Author 8 hours ago, Manie said: Are you not going to do it in C# ? Yes, in the long run I would like to use C#, mainly cause some home automation stuff I already have is written in C#. But I can't figure out how the inverter protocol, or at least the communications to / from it, and plonkster shared some python code that works, to some degree.
September 12, 20169 yr 27 minutes ago, TinkerBoy said: Lets just say we have been around that block. Why JDP why?
September 12, 20169 yr 1 hour ago, The Terrible Triplett said: Why JDP why? There are days when I'm glad to be of a phlegmatic temperament. It means I can look at these disagreements, agree with both parties (because I sorta see your point, but it is too much trouble to explain the opposing view), and then go off and do whatever the **** I wanted to in the first place. :-)
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.