示例#1
0
文件: AudioAlsa.cpp 项目: uro5h/lmms
/**
 * @brief Creates a list of all available devices.
 *
 * Uses the hints API of ALSA to collect all devices. This also includes plug
 * devices. The reason to collect these and not the raw hardware devices
 * (e.g. hw:0,0) is that hardware devices often have a very limited number of
 * supported formats, etc. Plugs on the other hand are software components that
 * map all types of formats and inputs to the hardware and therefore they are
 * much more flexible and more what we want.
 *
 * Further helpful info http://jan.newmarch.name/LinuxSound/Sampled/Alsa/.
 *
 * @return A collection of devices found on the system.
 */
AudioAlsa::DeviceInfoCollection AudioAlsa::getAvailableDevices()
{
	DeviceInfoCollection deviceInfos;

	char **hints;

	/* Enumerate sound devices */
	int err = snd_device_name_hint(-1, "pcm", (void***)&hints);
	if (err != 0)
	{
		return deviceInfos;
	}

	char** n = hints;
	while (*n != NULL)
	{
		char *name = snd_device_name_get_hint(*n, "NAME");
		char *description = snd_device_name_get_hint(*n, "DESC");

		if (name != 0 && description != 0)
		{
			deviceInfos.push_back(DeviceInfo(QString(name), QString(description)));
		}

		free(name);
		free(description);

		n++;
	}

	//Free the hint buffer
	snd_device_name_free_hint((void**)hints);

	return deviceInfos;
}
void
RealSenseDeviceManager::populateDeviceList ()
{
  device_list_.clear ();
  capture_manager_ = createCaptureManager();

  // Module description to match
  // PXCSession::ImplDesc module_desc = {};
  // module_desc.group = PXCSession::IMPL_GROUP_SENSOR;
  // module_desc.subgroup = PXCSession::IMPL_SUBGROUP_VIDEO_CAPTURE;
  if (capture_manager_->get_device_count() == 0) throw std::runtime_error("No device detected. Is it plugged in?");

  for (int m = 0; m < capture_manager_->get_device_count(); m++)
  {
    boost::shared_ptr<rs::device> device = createCaptureDevice(*capture_manager_, m);
       
    device_list_.push_back (DeviceInfo ());
    device_list_.back ().serial = device->get_serial();
    device_list_.back ().name = device->get_name();
    device_list_.back ().firmware_version = device->get_firmware_version();
    device_list_.back ().idx = m;
    //device_list_.back ().device_ptr = device;

  }
}
    void split(const GpuMat& src, GpuMat* dst, const cudaStream_t& stream) 
    {
        CV_Assert(dst);

        bool double_ok = TargetArchs::builtWith(NATIVE_DOUBLE) && 
                         DeviceInfo().supports(NATIVE_DOUBLE);
        CV_Assert(src.depth() != CV_64F || double_ok);

        int depth = src.depth();
        int num_channels = src.channels();
        Size size = src.size();

        if (num_channels == 1)
        {
            src.copyTo(dst[0]);
            return;
        }

        for (int i = 0; i < num_channels; ++i)
            dst[i].create(src.size(), depth);

        CV_Assert(num_channels <= 4);

        DevMem2D dst_as_devmem[4];
        for (int i = 0; i < num_channels; ++i)
            dst_as_devmem[i] = dst[i];

        DevMem2D src_as_devmem(src);
        split_merge::split_caller(src_as_devmem, dst_as_devmem,
                                  num_channels, src.elemSize1(), 
                                  stream);
    }
示例#4
0
LOCAL void REGPARMS
StartNextInternalRequest (ADAPTER_PTR HA)
{
  IO_REQ_PTR IReq = &HA->Ext->InternalRequest;
  IO_REQ_PTR XReq;
  int i;
  
  TRACE(2, ("StartNextInternalRequest(): InUse flag == %s\n",
      (HA->State.InternalReqInUse) ? "True" : "False"));
  
  critical(HA);
  while (!HA->State.InternalReqInUse
      && HA->Ext->InternalReqDeferQueue != (IO_REQ_PTR)NILL) {
    
    HA->State.InternalReqInUse = TRUE;
    XReq = HA->Ext->InternalReqDeferQueue;

    uncritical(HA);

    ReqTargetID(IReq) = ReqTargetID(XReq);
    ReqTargetLUN(IReq) = ReqTargetLUN(XReq);
    ReqDevP(IReq) = ReqDevP(XReq);

    for (i=0; i<12;i++)
      ReqCDB(IReq)[i] = 0;

    ReqState(IReq).ReqType = ReqState(XReq).ReqType;
    switch(ReqState(XReq).ReqType) {

    case RTGetInfoReq:

      DeviceInfo(HA);
      break;

      
    case RTAutoSenseReq:

      AutoSense(HA);
      break;

      
    case RTSyncNegReq:

      DoTestUnitReady(HA);
      break;

      
    default:
      CompleteDeferedRequest(HA, S_REQ_REQUEST);
      continue;
      
    }

    critical(HA);
  }
  uncritical(HA);

}
示例#5
0
		void DeviceManager::registerDevice( const char* name, int deviceType, NeutronPlugin* plugin )
		{
			if( name != 0 && name[0] != '\0' && deviceType != DT_Unknown && plugin != 0 )
			{
				Log::message( "DeviceManager", String::format( "Register device %s type = %d\n", name, deviceType ).getCStr() );
				deviceInfo.add( Math::Hash::DJB32( name ), DeviceInfo( deviceType, name, plugin ) );
				createDevice( name );
			}
		}
示例#6
0
std::vector<DeviceInfo> UsbHandler::get_device_list ()
{
    libusb_device** devs;

    int cnt = libusb_get_device_list(this->session->get_session(), &devs);

    if (cnt < 0)
    {
        throw std::runtime_error("Unable to retrieve device list. " + std::to_string(cnt));
    }

    std::vector<DeviceInfo> ret;
    ret.reserve(5);

    for (ssize_t i = 0; i < cnt; i++)
    {
        libusb_device_descriptor desc;
        int r = libusb_get_device_descriptor(devs[i], &desc);
        if (r < 0)
        {
            throw std::runtime_error("Unable to retrieve device descriptor. " + std::to_string(cnt));
        }

        // ignore all devices that are not from TIS or otherwise needed
        if (desc.idVendor != 0x199e)
            continue;

        if (desc.idProduct != 0x8209 && desc.idProduct != 0x0804)
            continue;

        tcam_device_info d = { };

        d.type = TCAM_DEVICE_TYPE_LIBUSB;

        libusb_device_handle* dh;
        r = libusb_open(devs[i], &dh);

        if (r < 0)
        {
            tcam_log(TCAM_LOG_ERROR, "Unable to open device.");
            continue;
        }

        snprintf((char*)d.additional_identifier, sizeof(d.additional_identifier),
                 "%x", desc.idProduct);

        libusb_get_string_descriptor_ascii(dh, desc.iProduct, (unsigned char*)d.name, sizeof(d.name));
        libusb_get_string_descriptor_ascii(dh, desc.iSerialNumber, (unsigned char*)d.serial_number, sizeof(d.serial_number));

        libusb_close(dh);
        ret.push_back(DeviceInfo(d));
    }

    libusb_free_device_list(devs, 1);

    return ret;
}
示例#7
0
	//---------------
	DeviceInfo ^ Bus::getDeviceInfo(long deviceNumber) {
		long model;
		long serial;
		long version;
		long address;
		GetDeviceInfo(deviceNumber, &model, &serial, &version, &address);

		DeviceInfo ^ d = gcnew DeviceInfo();
		d->model = model;
		d->serial = serial;
		d->version = version;
		d->address = address;

		return d;
	}
void RegisterDevice(const char* deviceName, MM::DeviceType deviceType, const char* deviceDescription)
{
   if (!deviceName)
      return;

   if (!deviceDescription)
      // This is a bug; let the programmer know by displaying an ugly string
      deviceDescription = "(Null description)";

   if (std::find_if(g_registeredDevices.begin(), g_registeredDevices.end(),
            DeviceNameMatches(deviceName)) != g_registeredDevices.end())
      // Device with this name already registered
      return;

   g_registeredDevices.push_back(DeviceInfo(deviceName, deviceType, deviceDescription));
}
    void merge(const GpuMat* src, size_t n, GpuMat& dst, const cudaStream_t& stream) 
    {
        CV_Assert(src);
        CV_Assert(n > 0);
       
        bool double_ok = TargetArchs::builtWith(NATIVE_DOUBLE) && 
                         DeviceInfo().supports(NATIVE_DOUBLE);
        CV_Assert(src[0].depth() != CV_64F || double_ok);

        int depth = src[0].depth();
        Size size = src[0].size();

        bool single_channel_only = true;
        int total_channels = 0;

        for (size_t i = 0; i < n; ++i)
        {
            CV_Assert(src[i].size() == size);
            CV_Assert(src[i].depth() == depth);
            single_channel_only = single_channel_only && src[i].channels() == 1;
            total_channels += src[i].channels();
        }

        CV_Assert(single_channel_only);
        CV_Assert(total_channels <= 4);

        if (total_channels == 1)  
            src[0].copyTo(dst);
        else 
        {
            dst.create(size, CV_MAKETYPE(depth, total_channels));

            DevMem2D src_as_devmem[4];
            for(size_t i = 0; i < n; ++i)
                src_as_devmem[i] = src[i];

            DevMem2D dst_as_devmem(dst);
            split_merge::merge_caller(src_as_devmem, dst_as_devmem,
                                      total_channels, CV_ELEM_SIZE(depth),
                                      stream);
        }   
    }
示例#10
0
eOSState cSatipPluginSetup::ProcessKey(eKeys keyP)
{
  bool hadSubMenu = HasSubMenu();
  int oldOperatingMode = operatingModeM;
  int oldCiExtension = ciExtensionM;
  int oldNumDisabledSources = numDisabledSourcesM;
  int oldNumDisabledFilters = numDisabledFiltersM;
  eOSState state = cMenuSetupPage::ProcessKey(keyP);

  // Ugly hack with hardcoded '+/-' characters :(
  const char *p = Get(Current())->Text();
  if (!hadSubMenu && !HasSubMenu() && p && (*p == '+' || *p == '-') && (keyP == kOk))
     return DeviceInfo();
  if (hadSubMenu && !HasSubMenu())
     Setup();

  if (state == osUnknown) {
     switch (keyP) {
       case kRed:    return DeviceScan();
       case kYellow: return ShowDeviceStatus();
       case kBlue:   return ShowInfo();
       case kInfo:   if (Current() < helpM.Size())
                        return AddSubMenu(new cMenuText(cString::sprintf("%s - %s '%s'", tr("Help"), trVDR("Plugin"), PLUGIN_NAME_I18N), helpM[Current()]));
       default:      state = osContinue; break;
       }
     }

  if ((keyP == kNone) && (cSatipDiscover::GetInstance()->GetServers()->Count() != deviceCountM))
     Setup();

  if ((keyP != kNone) && ((numDisabledSourcesM != oldNumDisabledSources) || (numDisabledFiltersM != oldNumDisabledFilters) || (operatingModeM != oldOperatingMode) || (ciExtensionM != oldCiExtension) || (detachedModeM != SatipConfig.GetDetachedMode()))) {
     while ((numDisabledSourcesM < oldNumDisabledSources) && (oldNumDisabledSources > 0))
           disabledSourcesM[--oldNumDisabledSources] = cSource::stNone;
     while ((numDisabledFiltersM < oldNumDisabledFilters) && (oldNumDisabledFilters > 0))
           disabledFilterIndexesM[--oldNumDisabledFilters] = -1;
     Setup();
     }

  return state;
}
示例#11
0
IDevice::DeviceInfo IDevice::deviceInformation() const
{
    const QString key = QCoreApplication::translate("ProjectExplorer::IDevice", "Device");
    return DeviceInfo() << IDevice::DeviceInfoItem(key, deviceStateToString());
}
示例#12
0
void * DevicePolling(void * host_number) // thread
{
    unsigned char poll_en = 0;
    unsigned int time_poll = 30000;
    unsigned char destroy = 0;
    int host = (int) host_number;
    unsigned char trying_time = 0, dev_disconnect_try_time = 3;
    float_struct_t my_float;

    if  (host < 0 || host >= DEV_HOST_NUMBER)
    {
        printf("Host number not valid.\r\nIt should be greater or equal zero and lester than %d.\r\n", DEV_HOST_NUMBER);
        printf("Thread exiting.\r\n");
        pthread_exit(NULL);
    }

    printf("Thread: %d start with host: %d.\n",
           (int)polling_thread[host], host);

    while(1)
    {
        if (pthread_mutex_trylock(&device_control_access) == 0)
        {
            poll_en = dev_host[host].polling_control.enable;
            time_poll = dev_host[host].polling_control.time_poll_ms * 1000;
            destroy = dev_host[host].polling_control.destroy;
            pthread_mutex_unlock(&device_control_access);
        }
        else
        {
            printf("Thread: %d. host: %d. Fail to access device control.\n",
                   (int)polling_thread[host], host);
            usleep(1000);
        }

        if (destroy)
        {
            printf("Thread: %d. host: %d. Destroying.\n",
                   (int)polling_thread[host], host);
            pthread_exit(NULL);
        }

        if (poll_en)
        {
            //while (pthread_mutex_trylock(&device_control_access) != 0)
            //usleep(1000);
            if (dev_host[host].type != DEV_UNKNOWN) // already known device type
            {
                trying_time = 0;
                while (pthread_mutex_trylock(&serial_access) != 0)
                {
                    usleep(1000);
                    trying_time ++;
                    if (trying_time > 10)
                        break;
                }
                if (trying_time > 10)
                {
#if DEVICE_DEBUG
                    printf("Thread: %d. host: %d. Fail to access serial port.\n",
                           (int)polling_thread[host], host);
#endif
                    //pthread_mutex_unlock(&device_control_access);
                    usleep(time_poll);
                    continue;
                }
                else
                {
                    RaspiExt_Pin_Hostx_Active(host + 1);
                    if (queryData(&dev_host[host]))
                    {
#if DEVICE_DEBUG
                        printf("Thread: %d. host: %d. Got data from device.\n",
                               (int)polling_thread[host], host);
                        DeviceInfo(&dev_host[host]);
#endif
                        dev_disconnect_try_time = 3;
                    }
                    else
                    {
#if DEVICE_DEBUG
                        printf("Thread: %d. host: %d. No device here.\n",
                               (int)polling_thread[host], host);
#endif
                        if (dev_disconnect_try_time == 0)
                        {
                            // TODO: unregister this device
                            unsigned char reg_id = dev_host[host].number | dev_host[host].type;
                            printf("Thread: %d. host: %d. Unregister device %X.\n",
                                   (int)polling_thread[host],
                                   host,
                                   reg_id);
                            UnRegisterID(&reg_id);
                            if (IS_MY_THESIS(DEV_TYPE_MASK(dev_host[host].type)))
                            {
                                if (dev_host[host].data != NULL)
                                    memset(dev_host[host].data, 0, sizeof(struct ThesisData));
                            }
                            else
                            {
                                if (dev_host[host].data != NULL)
                                    memset(dev_host[host].data, 0, getTypeLength(dev_host[host].type));
                            }
                            dev_host[host].type = DEV_UNKNOWN;
                            dev_host[host].number = DEV_NUMBER_UNKNOWN;
                        }
                        else
                        {
                            dev_disconnect_try_time--;
                        }
                    }
                    RaspiExt_Pin_Hostx_Inactive(host + 1);
                }
                pthread_mutex_unlock(&serial_access);

                switch (dev_host[host].type)
                {
                case DEV_SENSOR_TEMPERATURE:
                    RaspiExt_LED_Hostx_Config(LED_MODE_TOGGLE, 1000, host + 1);

                    if (IS_BIG_ENDIAN_BYTE_ORDER(dev_host[host].data_type))
                    {
                        my_float.f_byte[0] = dev_host[host].data[3];
                        my_float.f_byte[1] = dev_host[host].data[2];
                        my_float.f_byte[2] = dev_host[host].data[1];
                        my_float.f_byte[3] = dev_host[host].data[0];
                    }
                    else
                    {
                        my_float.f_byte[0] = dev_host[host].data[0];
                        my_float.f_byte[1] = dev_host[host].data[1];
                        my_float.f_byte[2] = dev_host[host].data[2];
                        my_float.f_byte[3] = dev_host[host].data[3];
                    }
                    printf("Thread: %d. host: %d. Temperature: %0.3f.\n",
                           (int)polling_thread[host],
                           host,
                           my_float.f);

                    // adjust time polling
                    if (pthread_mutex_trylock(&device_control_access) == 0)
                    {
                        dev_host[host].polling_control.time_poll_ms = 50;
                    }
                    else
                    {
                        printf("Thread: %d. host: %d. Fail to access device control.\n",
                               (int)polling_thread[host],
                               host);
                    }

                    // save to shared memory

                    break;
                case DEV_SENSOR_ULTRA_SONIC:
                    RaspiExt_LED_Hostx_Config(LED_MODE_TOGGLE, 100, host + 1);

                    my_float.f_byte[0] = dev_host[host].data[3];
                    my_float.f_byte[1] = dev_host[host].data[2];
                    my_float.f_byte[2] = dev_host[host].data[1];
                    my_float.f_byte[3] = dev_host[host].data[0];
                    printf("Thread: %d. host: %d. Distance: %0.3f.\n",
                           (int)polling_thread[host],
                           host,
                           my_float.f);

                    // put to db
#if DATABASE
                    //// put this device into database
                    //if (DB_IsExist_sensors(dev_host[host].number, dev_host[host].type, UltraSonic_name,
                    //UltraSonic_code, UltraSonic_symbol, 30, 10, UltraSonic_unit) == 0) // not exist
                    //{
                    //DB_Record_sensors(dev_host[host].number, dev_host[host].type, UltraSonic_name,
                    //UltraSonic_code, UltraSonic_symbol, 30, 10, UltraSonic_unit);
                    //}
                    //if (DB_IsExist_sensor_types(dev_host[host].type, UltraSonic_name, UltraSonic_description) == 0) // not exist
                    //{
                    //DB_Record_sensor_types(dev_host[host].type, UltraSonic_name, UltraSonic_description);
                    //}
                    ////DB_Record_sensor_values(dev_host[host].type, UltraSonic_name, UltraSonic_description);
                    DB_Record_sensor_values_short(my_float.f, millis()/1000);
#endif

                    // adjust time polling

                    // save to shared memory

                    break;
                case DEV_SENSOR_LIGTH:
                    RaspiExt_LED_Hostx_Config(LED_MODE_TOGGLE, 50, host + 1);
                    break;
                case DEV_RF:
                    break;
                case DEV_BLUETOOTH:
                    break;
                case DEV_BUZZER:
                    break;
                case DEV_SENSOR_GAS:
                    RaspiExt_LED_Hostx_Config(LED_MODE_TOGGLE, 50, host + 1);
                    break;
                case DEV_SIM900:
                    break;
                case DEV_MY_THESIS:
                    RaspiExt_LED_Hostx_Config(LED_MODE_TOGGLE, 1000, host + 1);
                    break;
                default:
#if DEVICE_DEBUG
                    printf("Thread: %d. host: %d. Unknown device type.\n",
                           (int)polling_thread[host], host);
#endif
                    dev_host[host].type = DEV_UNKNOWN;
                    dev_host[host].number = DEV_NUMBER_UNKNOWN;
                    break;
                }
            }
            else // unknown device type
            {
                RaspiExt_LED_Hostx_Config(LED_MODE_OFF, 50, host + 1);

#if DEVICE_DEBUG
                printf("Thread: %d. host: %d. Unknown device, identifying.\n",
                       (int)polling_thread[host], host);
#endif

                // query broadcast id to identify what it is
                // adjust time polling to 500 ms
                time_poll = 500000;


                trying_time = 0;
                while (pthread_mutex_trylock(&serial_access) != 0)
                {
                    usleep(1000);
                    trying_time ++;
                    if (trying_time > 10)
                    {
                        break;
                    }
                }
                if (trying_time > 10)
                {
#if DEVICE_DEBUG
                    printf("Thread: %d. host: %d. Fail to access serial port.\n",
                           (int)polling_thread[host], host);
#endif
                    usleep(time_poll);
                    continue;
                }
                else
                {
#if DEVICE_DEBUG
                    //dev_host[host].type = DEV_SENSOR_ULTRA_SONIC;
                    //dev_host[host].number = 0x01;
#endif
                    RaspiExt_Pin_Hostx_Active(host + 1);
                    if (queryData(&dev_host[host]))
                    {
#if DEVICE_DEBUG
                        printf("Thread: %d. host: %d. Got data from device.\n",
                               (int)polling_thread[host], host);
#endif
                        // TODO: register new id
                        unsigned char reg_id = dev_host[host].type | dev_host[host].number;
                        if (RegisterID(&reg_id) != 0)
                        {
                            printf("Thread: %d. host: %d. Fail to register new device.\n",
                                   (int)polling_thread[host],
                                   host);
                        }
                        else
                        {
                            printf("Thread: %d. host: %d. Registered new device %X.\n",
                                   (int)polling_thread[host],
                                   host,
                                   reg_id);
                        }
                        dev_host[host].type = DEV_TYPE_MASK(reg_id);
                        dev_host[host].number = DEV_NUMBER_MASK(reg_id);
                        sendControl(dev_host[host]);
                    }
                    else
                    {
#if DEVICE_DEBUG
                        printf("Thread: %d. host: %d. No device here.\n",
                               (int)polling_thread[host], host);
#endif

                    }
                    RaspiExt_Pin_Hostx_Inactive(host + 1);
                }

                pthread_mutex_unlock(&serial_access);
            }
            usleep(time_poll);

            //pthread_mutex_unlock(&device_control_access);
        }// query device

    }
}
示例#13
0
int queryData(struct Device * dev)
{
    int packet_len, data_len;
    struct Packet * packet = malloc(128);

    if (dev->data == NULL)
    {
        if (IS_MY_THESIS(dev->type))
        {
            dev->data = malloc(sizeof (struct ThesisData));
            memset(dev->data, 0, sizeof (struct ThesisData));
        }
        else
        {
            dev->data = malloc(getTypeLength(dev->data_type));
            memset(dev->data, 0, getTypeLength(dev->data_type));
        }
    }

#if DEVICE_DEBUG
    printf("Query Device: \n");
    DeviceInfo(dev);
#endif

    if (IS_MY_THESIS(dev->type))
    {
        data_len = sizeof(struct ThesisData);
        packet_len = 4 + data_len;
        //packet = malloc(packet_len);
    }
    else
    {
        data_len = getTypeLength(dev->data_type);
        packet_len = 4 + data_len;
        //packet = malloc(packet_len);
    }

    packet->id = dev->number | dev->type;
    packet->cmd = CMD_TYPE_QUERY;
#if __BYTE_ORDER == __BIG_ENDIAN
    packet->data_type = DEV_TYPE_MASK(dev->data_type) | BIG_ENDIAN_BYTE_ORDER;
#else
    packet->data_type = DEV_TYPE_MASK(dev->data_type) | LITTLE_ENDIAN_BYTE_ORDER;
#endif
    memcpy(packet->data, dev->data, data_len);
    // add checksum byte
    packet->data[data_len] = checksum((char *)packet);

#if DEVICE_DEBUG
    printf("Query Packet: ");
    int i;
    for (i = 0; i < packet_len + 1; i++)
    {
        printf("%02X ", *((unsigned char *) packet + i));
    }
    printf("Checksum: %02X.\n", *(((char *)packet) + packet_len));
    printf("\n");
#endif

    Serial_SendMultiBytes((unsigned char *) packet, packet_len);
    // sleep 5ms for timeout
    usleep(5000);
    packet_len = Serial_Available();
    if (packet_len)
    {
        Serial_GetData((char *) packet, packet_len);
        // checksum check
        if (checksum((char *)packet) != packet->data[getTypeLength(packet->data_type)])
        {
#if DEVICE_DEBUG
            printf("Wrong checksum.\n");
#endif
            // what should to do now?
            if (packet != NULL)
            {
                free(packet);
                packet = NULL;
            }
            return 0;
        }

#if DEVICE_DEBUG
        printf("Received Packet: ");
        int i;
        for (i = 0; i < packet_len + 1; i++)
        {
            printf("%02X ", *((unsigned char *) packet + i));
        }
        printf("Checksum: %02X.\n", *(((char *)packet) + packet_len));
        printf("\n");
#endif

        // reallocating memory if not old data type
        if (dev->data_type != DATA_TYPE_MASK(packet->data_type))
        {
            if (dev->data != NULL)
                free(dev->data);
            if (IS_MY_THESIS(DEV_TYPE_MASK(packet->id)))
            {
                dev->data = malloc(sizeof(struct ThesisData));
            }
            else
            {
                dev->data = malloc(getTypeLength(DATA_TYPE_MASK(packet->data_type)));
            }
        }

        dev->data_type = DATA_TYPE_MASK(packet->data_type);
        dev->type = DEV_TYPE_MASK(packet->id);
        dev->number = DEV_NUMBER_MASK(packet->id);
        if (IS_MY_THESIS(DEV_TYPE_MASK(packet->id)))
        {
            dev->polling_control.time_poll_ms = 500;
            memcpy(dev->data, packet->data, sizeof (struct ThesisData));
        }
        else
        {
            memcpy(dev->data, packet->data, getTypeLength(packet->data_type));
        }
        if (packet != NULL)
        {
            free(packet);
            packet = NULL;
        }
        return packet_len;
    }
    else
    {
        if (packet != NULL)
        {
            free(packet);
            packet = NULL;
        }
        return 0;
    }
}
示例#14
0
IDevice::DeviceInfo DesktopDevice::deviceInformation() const
{
    return DeviceInfo();
}