/*****************************************************************************
*   driving logic
*****************************************************************************/
int main( int argc, char *argv[]) {
    AsyncAPI api;

    // successful write(): prime AsyncAPI with some data
    write( api, "abcd");
    // successful read(): retrieve it
    std::string data( read( api) );
    assert( data == "abcd");

    // successful write_ec()
    AsyncAPI::errorcode ec( write_ec( api, "efgh") );
    assert( ec == 0);

    // write_ec() with error
    api.inject_error(1);
    ec = write_ec( api, "ijkl");
    assert( ec == 1);

    // write() with error
    std::string thrown;
    api.inject_error(2);
    try {
        write(api, "mnop");
    } catch ( std::exception const& e) {
        thrown = e.what();
    }
    assert( thrown == make_exception("write", 2).what() );

    // successful read_ec()
//[callbacks_read_ec_call
    std::tie( ec, data) = read_ec( api);
//]
    assert( ! ec);
    assert( data == "efgh");         // last successful write_ec()

    // read_ec() with error
    api.inject_error(3);
    std::tie( ec, data) = read_ec( api);
    assert( ec == 3);
    // 'data' in unspecified state, don't test

    // read() with error
    thrown.clear();
    api.inject_error(4);
    try {
        data = read(api);
    } catch ( std::exception const& e) {
        thrown = e.what();
    }
    assert( thrown == make_exception("read", 4).what() );

    std::cout << "done." << std::endl;

    return EXIT_SUCCESS;
}
static int __init init_fan_module(void)
{
  char name[16]="acer_fan_control";
  printk(KERN_CRIT "Fan control started\n");
  // turn BIOS fan control off  
  write_ec(0x93, 0x14);

  printk(KERN_INFO "in init");
  thread1 = kthread_run(thread_fn,NULL,name);
  
  return 0;
}
Beispiel #3
0
void write_smbus(ec_dev_t* dev, uint8_t reg, uint8_t data)
{
    write_ec(dev, reg+dev->smbus_offset, data);
}
//[callbacks_write
void write( AsyncAPI & api, std::string const& data) {
    AsyncAPI::errorcode ec = write_ec( api, data);
    if ( ec) {
        throw make_exception("write", ec);
    }
}
static void set_speed(short speed)
{
  write_ec(0x94, (255-(speed * 135) / 100));
}