Compare commits
9 Commits
Author | SHA1 | Date |
---|---|---|
DrMaxNix | 369c13f9f9 | |
DrMaxNix | 66f207399f | |
DrMaxNix | f624a2ed7e | |
DrMaxNix | e37b471763 | |
DrMaxNix | 315baa70cf | |
DrMaxNix | b4f5170269 | |
DrMaxNix | a5d1ecb3aa | |
DrMaxNix | bf39c2a60b | |
DrMaxNix | ba3511c4e7 |
12
README.md
12
README.md
|
@ -1,6 +1,6 @@
|
|||
# phoenix-upshid
|
||||
[![GitHub release](https://img.shields.io/badge/release-v1.0.1-orange)](https://github.com/DrMaxNix/phoenix-upshid/releases/tag/1.0.1)
|
||||
[![License](https://img.shields.io/badge/license-MIT-green)](https://github.com/DrMaxNix/phoenix-upshid/blob/main/LICENSE)
|
||||
[![Release](https://img.shields.io/badge/release-v1.0.2-orange)](https://git.tjdev.de/DrMaxNix/phoenix-upshid/releases/tag/v1.0.2)
|
||||
[![License](https://img.shields.io/badge/license-MIT-green)](https://git.tjdev.de/DrMaxNix/phoenix-upshid/src/branch/main/LICENSE)
|
||||
[![Maintaner](https://img.shields.io/badge/maintainer-DrMaxNix-blue)](https://www.drmaxnix.de)
|
||||
|
||||
Simple driver for reading data from Phoenixtec ("Amazon Basics") UPSes written in c
|
||||
|
@ -14,16 +14,16 @@ I tried multiple drivers for it, but they all had their problems:
|
|||
|
||||
So I tried writing dirty fixes for both of those drivers, which would reset the USB connection when detecting such problem. But it wasn't as stable as I had hoped.
|
||||
|
||||
At the end I [reverse-engineered](https://github.com/DrMaxNix/phoenix-upshid/blob/main/nut-reverseengineering.md) the USB-HID protocol of the UPS and wrote my own driver for it in c, which has the reset-capability built-in. I'm not at all into c driver development, so use this at your own risk, as the license already states: "WITHOUT WARRANTY OF ANY KIND"!
|
||||
At the end I [reverse-engineered](https://git.tjdev.de/DrMaxNix/phoenix-upshid/src/branch/main/nut-reverseengineering.md) the USB-HID protocol of the UPS and wrote my own driver for it in c, which has the reset-capability built-in. I'm not at all into c driver development, so use this at your own risk, as the license already states: "WITHOUT WARRANTY OF ANY KIND"!
|
||||
|
||||
|
||||
|
||||
## How to use
|
||||
Download and extract source and compile:
|
||||
```console
|
||||
$ wget https://github.com/DrMaxNix/phoenix-upshid/archive/refs/tags/1.0.1.tar.gz
|
||||
$ tar xf 1.0.1.tar.gz
|
||||
$ cd phoenix-upshid-1.0.1
|
||||
$ wget https://git.tjdev.de/DrMaxNix/phoenix-upshid/archive/v1.0.2.tar.gz
|
||||
$ tar xf v1.0.2.tar.gz
|
||||
$ cd phoenix-upshid
|
||||
$ gcc -o phoenix-upshid phoenix-upshid.c
|
||||
```
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ void print_version();
|
|||
|
||||
|
||||
// PUBLIC FLAGS //
|
||||
int auto_usbreset = false;
|
||||
bool auto_usbreset = false;
|
||||
|
||||
uint16_t vendor_id;
|
||||
uint16_t product_id;
|
||||
|
@ -108,7 +108,7 @@ int main(int argc, char **argv){
|
|||
}
|
||||
|
||||
// parse
|
||||
for(size_t q = optind; q < argc; q++){
|
||||
for(int q = optind; q < argc; q++){
|
||||
if(q == optind){
|
||||
// make sure string has a collon in it
|
||||
char *arg_id = argv[q];
|
||||
|
@ -396,7 +396,7 @@ void output_data(){
|
|||
// charge and remaining time
|
||||
int values_res;
|
||||
char values_buffer[64];
|
||||
for(size_t q = 0; q <= 1; q++){
|
||||
for(int q = 0; q <= 1; q++){
|
||||
values_buffer[0] = 0x06;
|
||||
values_res = ioctl(hid, HIDIOCGFEATURE(256), values_buffer);
|
||||
if(values_res >= 4){
|
||||
|
@ -421,7 +421,7 @@ void output_data(){
|
|||
// flaggs (charging, discharging, line power, low battery)
|
||||
int flaggs_res;
|
||||
char flaggs_buffer[64];
|
||||
for(size_t q = 0; q <= 1; q++){
|
||||
for(int q = 0; q <= 1; q++){
|
||||
flaggs_buffer[0] = 0x01;
|
||||
flaggs_res = ioctl(hid, HIDIOCGFEATURE(256), flaggs_buffer);
|
||||
if(flaggs_res >= 5){
|
||||
|
@ -482,22 +482,22 @@ void usbreset(){
|
|||
// DO RESET //
|
||||
// send command
|
||||
if(ioctl(bus, USBDEVFS_RESET, 0) < 0){
|
||||
fprintf(stderr, "[WARN ] Unable to do usbreset\n");
|
||||
fprintf(stderr, "[WARN ] Unable to do usbreset\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// success!
|
||||
fprintf(stderr, "[INFO ] Usbreset successful\n");
|
||||
fprintf(stderr, "[INFO ] Usbreset successful\n");
|
||||
|
||||
// close file
|
||||
close(bus);
|
||||
close(bus);
|
||||
}
|
||||
|
||||
/*
|
||||
HELPER: Print version and exit
|
||||
*/
|
||||
void print_version(){
|
||||
printf("phoenix-upshid v1.0.1 | (c) DrMaxNix 2022 | www.drmaxnix.de/phoenix-upshid\n");
|
||||
printf("phoenix-upshid v1.0.2 | (c) DrMaxNix 2022 | www.drmaxnix.de/phoenix-upshid\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue