Comments (6)
Thanks for reporting this! And thank you that you attached example data. That is a good start to find a better way.
The current solution is a pretty basic approach.
A far better approach would it be to fill the buffer and check if we found a valid packed until we found one or the buffer has reached its max size.
from esphome_samsung_ac.
Tried this in 'my' fork in the second part of void Samsung_AC::loop(), and it seems to work fine (declared bytes_ and size_ as uint16_t in samsung_ac.h):
last_transmission_ = now;
while (available())
{
uint8_t c;
read_byte(&c);
if (c == 0x32 && !receiving_) // start-byte found
{
receiving_ = true;
bytes_ = 0;
size_ = 0;
data_.clear();
}
if (receiving_)
{
data_.push_back(c);
bytes_++;
switch (bytes_)
{
case 1: // start byte found
break;
case 2: // first part of size found
{
size_ = c;
break;
}
case 3: // second part of size found
{
size_ = (int)size_ << 8 | c;
ESP_LOGV(TAG, "Message size in packet: %d", size_);
break;
}
default: // subsequent bytes
{
if (bytes_ >= (size_+2)) // end byte found
{
receiving_ = false;
process_message(data_, this);
}
break;
}
}
}
}
from esphome_samsung_ac.
The problem with that solution is that it only works for the NASA protocol. I will try to find a more general solution next week.
from esphome_samsung_ac.
I now have commited a solution to that. May you have a look?
from esphome_samsung_ac.
Hi, checked for NASA protocol on my SAMSUNG heatpump and all seems to work fine, data is read correctly. So regression test wise: looks good. However, I don't think that my current data stream includes the 0x34 end byte as part of the data, so we have no 100% proof that the original issue is definitively solved. And I do not know how to manipulate the data stream to create a test case. So what shall we do with this issue, close it for now?
from esphome_samsung_ac.
👍🏻
from esphome_samsung_ac.
Related Issues (20)
- Did I fry my 485 unit? HOT 6
- file example.yaml is all in errors when you try to get the firmware HOT 2
- [NASA] Automatic Cleaning HOT 12
- [Non-NASA] Unable to control AC HOT 11
- 120Ω needed on Nasa? - physical layer
- [NASA] Override Temperature Readings Of Indoor Unit HOT 2
- Control Samsung AC Windfree mode HOT 1
- Control Samsung AC Quiet mode HOT 1
- Control Samsung AC Purify mode HOT 1
- does this register contain COP or SCOP?
- [NASA] Control Beep Sound HOT 28
- [COMMON] The program size (2038817 bytes) is greater than maximum allowed (1835008 bytes) HOT 1
- Non Nasa test in esphome (Home Assistant) HOT 24
- Vertical swing mode not present - how to activate? HOT 3
- Different device but with known wire interface HOT 15
- [NonNASA] Warnings - Unsupported alt_mode 0 HOT 10
- Help identify protocol ar09nxfpewqneu HOT 1
- No Issue, just asking!
- [NASA] - compiler error on ESP-IDF HOT 4
- [NonNASA] I cannot control device from HA but it's receiving data HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esphome_samsung_ac.