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

connection failed: Input/output error #5

Open
clardima opened this issue Jan 28, 2021 · 5 comments
Open

connection failed: Input/output error #5

clardima opened this issue Jan 28, 2021 · 5 comments

Comments

@clardima
Copy link

Hi,

I try to connect to my SmartBMS the way you mention but I reciev an error:
sudo python3 bmstcp.py A4:C1:38:06:BC:A6 9998
[A4:C1:38:06:BC:A6] Connecting
[A4:C1:38:06:BC:A6] Connection failed: Input/output error

I am able to connect using gatttool:
sudo gatttool -i hci0 -b A4:C1:38:06:BC:A6 -I
[A4:C1:38:06:BC:A6][LE]> connect
Attempting to connect to A4:C1:38:06:BC:A6
Connection successful

Any idea what I could do?

Thanks

Maarten

@jdrescher2006
Copy link

Have you tried the bmsinfo.py? It works for me.

@clardima
Copy link
Author

clardima commented Feb 18, 2021

Thanks for your reply.
I was having difficulties with bluetooth on my raspberrypi, so I had to solve that first.

Now I am able to connect to the BMS's (I got 3 of them)
One of them is working, I can receive the data.

But the other 2, seem not to work. The script is freezing.

pi@raspberrypi:/clardibms $ sudo python3 bmsinfo.py A4:C1:38:06:BC:A6
BMS found
BMS request generic data
BMS answering
BMS answering
BMS answer: dd03001b0b4700001a251c2000002446000000000000195d0307020b4f0b4afd7d77
BMS request voltages
BMS answering
BMS answering
BMS answer: dd04000e101c101d101e101e101a101b101cfebc77
BMS chat ended
{
"Bal": 0,
"Ibat": 0.0,
"T1": 16.4,
"T2": 15.9,
"V01": 4.124,
"V02": 4.125,
"V03": 4.126,
"V04": 4.126,
"V05": 4.122,
"V06": 4.123,
"V07": 4.124,
"Vbat": 28.87
}
[A4:C1:38:06:BC:A6] Disconnected
pi@raspberrypi:
/clardibms $ sudo python3 bmsinfo.py A4:C1:38:40:18:39
BMS found
BMS request generic data
BMS answering

...and....

pi@raspberrypi:/clardibms $ sudo bluetoothctl
Agent registered
[xiaoxiang BMS]# scan on
Discovery started
[CHG] Controller B8:27:EB:4E:27:C6 Discovering: yes
[CHG] Device A4:C1:38:06:BC:A6 RSSI: -68
[CHG] Device A4:C1:38:57:7C:4B RSSI: -42
[xiaoxiang BMS]# connect A4:C1:38:57:7C:4B
Attempting to connect to A4:C1:38:57:7C:4B
[CHG] Device A4:C1:38:57:7C:4B Connected: yes
Connection successful
[CHG] Device A4:C1:38:57:7C:4B ServicesResolved: yes
[xiaoxiang BMS]# exit
pi@raspberrypi:
/clardibms $ sudo python3 bmsinfo.py A4:C1:38:57:7C:4B
BMS found
BMS request generic data
..(and it hangs....)

@jdrescher2006
Copy link

I have the same problem, sometimes the communication freezes:
./bmsinfo.py A4:C1:38:F2:6D:4E
BMS found
BMS request generic data

Currently I am working on making the script more robust, so as to repeat the request. Also I am looking to get more data from the BMS like SOC and other values.

@jdrescher2006
Copy link

I have discovered that it makes sense to wait a second before writing to the device. This makes communication much more stable.
Like that:
time.sleep(1)
self.bms_write_characteristic.write_value(bytes([0xDD,0xA5,0x03,0x00,0xFF,0xFD,0x77]));

Note that you need to import time for that.

@vx2200
Copy link

vx2200 commented Feb 26, 2021

I had the same stability issues and added a sleep between connection and write statement. This helps a lot. But, sometimes it still freezes. I increased the sleep to 2 seconds. This seems to fix this problem.

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

3 participants