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

write/read device help #104

Open
samuaz opened this issue Oct 20, 2021 · 1 comment
Open

write/read device help #104

samuaz opened this issue Oct 20, 2021 · 1 comment
Labels

Comments

@samuaz
Copy link

samuaz commented Oct 20, 2021

HI me again xD,

And thanks again for this project.

I'm trying to read your code to try to write an implementation to debug and support my M15R3 per key lights.
I'm not python developer, I'm c/c++/java developer.

Maybe you could help me clear up some doubts

I just start writing a small function that write to the device.
(Previously I write the function that search by vendor and save founded device in a pointer)

so my write functions looks like this

int Write(unsigned char* pData, int pDataLength)
{
  return libusb_control_transfer(alienware, SEND_REQUEST_TYPE, SEND_REQUEST,
                                 SEND_VALUE, SEND_INDEX, pData, pDataLength, 0);
}

where

alienware = founded alienware lights usb device
SEND_REQUEST_TYPE = 0x21
SEND_REQUEST = 0x09
SEND_VALUE = 0x202
SEND_INDEX = 0x00

I found this ^ in a very old documentation, so I'm not sure if are correct.

Then first question how is composed the data array that you send to the libusb_control_transfer?

pData = unsigned char data[9]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
  data[0] = START_BYTE ?;
  data[1] = THE_COMMAND example COMMAND_SET_COLOR ?;
  data[2] = HEX_ID ?;
  data[3] = zone?;
  data[4] = zone?;
  data[5] = zone?;
  data[6] = r ?;
  data[7] = g ?;
  data[8] = b ?;

How do you found the correct values here for a machine? Specially [0]START_BYTE, [1]command, [2]HEX_ID?

Thanks so much!!

@rsm-gh
Copy link
Owner

rsm-gh commented Nov 2, 2021

Hi @samuaz ,

It will probably take me long time to make you a formal answer because I lack of time, but in the mean time it may help you to know, you can visualize the data sent by akbl.

For doing that, just turn on the debug mode on akbl:

  1. modify the file: akbl/setup:
    DEBUG='True' 				# Python boolean
  1. re-install the software

A. to monitor the daemon:
3.1: stop the systemctl service: systemctl stop akbl
3.2: start the daemon in the current terminal: akbl --start-daemon. Execute the command as root, and you must only have 1 process.

example of the debug info:

_DEBUG from `/usr/lib/python3.9/AKBL/Engine/Driver.py` on method `write_constructor`:
packet=2:8:1:0:0:0:0:0:0	 legend=__save_block, block=1
packet=2:14:0:1:0:0:0:0:0	 legend=set_speed, speed=1

packet=2:8:1:0:0:0:0:0:0	 legend=__save_block, block=1
packet=2:3:1:0:0:128:0:240:0	 legend=add_light_zone: left_color=#0000FF, hex_id=128
packet=2:8:1:0:0:0:0:0:0	 legend=__save_block, block=1
packet=2:4:0:0:0:0:0:0:0	 legend=end_colors_line

B: Use the block testing window:
execute as root the command akbl --block-testing, and all the info will be logged in the terminal, example:

_DEBUG from `/usr/lib/python3.9/AKBL/Engine/Driver.py` on method `write_constructor`:
command output=9


_DEBUG from `/usr/lib/python3.9/AKBL/Engine/Driver.py` on method `read_device`:
msg=array('B', [16, 0, 0, 0, 0, 0, 0, 0])


_DEBUG from `/usr/lib/python3.9/AKBL/Engine/Driver.py` on method `write_constructor`:
packet=2:14:0:100:0:0:0:0:0	 legend=set_speed, speed=100

packet=2:3:1:0:0:1:36:128:0	 legend=add_light_zone: left_color=#204a87, hex_id=1
packet=2:4:0:0:0:0:0:0:0	 legend=end_colors_line

packet=2:5:0:0:0:0:0:0:0	 legend=end_block_line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants