#include #include #include #include #include #include #include #include "smu.h" int fd; struct smu_user_cmd_hdr *chdr; struct smu_user_reply_hdr *rhdr; unsigned char *cdata, *rdata; unsigned char buffer[1024]; static int sleepled(int state) { int rc; chdr->cmdtype = SMU_CMDTYPE_SMU; chdr->cmd = 0xee; chdr->data_len = 3; cdata[0] = 0x04; cdata[1] = 0x00; cdata[2] = state; rc = write(fd, chdr, sizeof(*chdr) + 3); if (rc < 0) { perror("error writing command"); return rc; } rc = read(fd, rhdr, 1024); if (rc < 0) { perror("error reading reply"); return rc; } printf("sleepled, status: %d, reply_len: %d\n", rhdr->status, rhdr->reply_len); return 0; } int main(int argc, char **argv) { chdr = (struct smu_user_cmd_hdr *)buffer; rhdr = (struct smu_user_reply_hdr *)buffer; cdata = &buffer[sizeof(*chdr)]; rdata = &buffer[sizeof(*rhdr)]; fd = open("/dev/smu", O_RDWR); if (fd == -1) { perror("can't open /dev/smu"); return -1; } if (argc < 2) { sleepled(1); usleep(100); sleepled(0); return 0; } sleepled(strtol(argv[1], NULL, 10)); return 0; }