Example #1
0
void C1WireByOWFS::GetDevice(const std::string inDir, const std::string dirname, /*out*/_t1WireDevice& device) const
{
    // OWFS device name format, see http://owfs.org/uploads/owfs.1.html#sect30
    // OWFS must be configured to use the default format ff.iiiiiiiiiiii, with :
    // - ff : family (1 byte)
    // - iiiiiiiiiiii : id (6 bytes)

    // Retrieve family from the first 2 chars
    device.family=ToFamily(dirname.substr(0,2));

    // Device Id (6 chars after '.')
    std::string id=dirname.substr(3,3+6*2);
    // OWFS give us the device ID inverted, so reinvert it
    char c;
    for (int i=0;i<6/2;i++)
    {
       int left_position=i*2;          // Point on first byte
       int right_position=(6-i-1)*2;   // Point on last byte
       c=id[left_position]; id[left_position]=id[right_position]; id[right_position]=c;
       c=id[left_position+1]; id[left_position+1]=id[right_position+1]; id[right_position+1]=c;
    }
    device.devid=id;
    
    // Filename (full path)
    device.filename=inDir;
    device.filename+="/" + dirname;
}
Example #2
0
   boost::shared_ptr<device::IDevice> CEngine::createDevice(const boost::filesystem::path& devicePath) const
   {
      const std::string filename = devicePath.filename().string();

      // OWFS device name format, see http://owfs.org/uploads/owfs.1.html#sect30
      // OWFS must be configured to use the default format ff.iiiiiiiiiiii, with :
      // - ff : family (1 byte)
      // - iiiiiiiiiiii : id (6 bytes)

      // Retrieve family from the first 2 chars
      EOneWireFamily family = ToFamily(filename.substr(0, 2));

      // Device Id (6 chars after '.')
      std::string id = filename.substr(3, 6 * 2);
      // OWFS give us the device ID inverted, so reinvert it
      for (int i = 0; i < 6 / 2; i++)
      {
         int left_position = i * 2;          // Point on first byte
         int right_position = (6 - i - 1) * 2;   // Point on last byte
         char c = id[left_position]; id[left_position] = id[right_position]; id[right_position] = c;
         c = id[left_position + 1]; id[left_position + 1] = id[right_position + 1]; id[right_position + 1] = c;
      }

      return createDevice(family, id, devicePath);
   }
Example #3
0
void C1WireByOWFS::GetDevice(const std::string &inDir, const std::string &dirname, /*out*/_t1WireDevice& device) const
{
    // OWFS device name format, see http://owfs.org/uploads/owfs.1.html#sect30
    // OWFS must be configured to use the default format ff.iiiiiiiiiiii, with :
    // - ff : family (1 byte)
    // - iiiiiiiiiiii : id (6 bytes)

    // Retrieve family from the first 2 chars
    device.family=ToFamily(dirname.substr(0,2));

    // Device Id (6 chars after '.')
    std::string id=dirname.substr(3,3+6*2);
    // OWFS give us the device ID inverted, so reinvert it
    for (int i=0;i<6/2;i++)
    {
		char c;
		int left_position = i * 2;          // Point on first byte
		int right_position=(6-i-1)*2;   // Point on last byte
		c=id[left_position]; id[left_position]=id[right_position]; id[right_position]=c;
		c=id[left_position+1]; id[left_position+1]=id[right_position+1]; id[right_position+1]=c;
    }
    device.devid=id;
    
    device.filename=inDir;
    if (device.family == Environmental_Monitors || device.family == smart_battery_monitor) {
        device.filename+="/" + dirname + "/" + nameHelper(dirname);;
    } else { 
        device.filename+="/" + dirname;
    }
}
Example #4
0
void C1WireForWindows::GetDevice(const std::string& deviceName, /*out*/_t1WireDevice& device) const
{
   // 1W-Kernel device name format : ff-iiiiiiiiiiii, with :
   // - ff : family (1 byte)
   // - iiiiiiiiiiii : id (6 bytes)

   // Retrieve family from the first 2 chars
   device.family=ToFamily(deviceName.substr(0,2));

   // Device Id (6 chars after '-')
   device.devid=deviceName.substr(3,3+6*2);

   // Filename (full path)
   device.filename=deviceName;
}
Example #5
0
void C1WireByKernel::GetDevice(const std::string& deviceName, /*out*/_t1WireDevice& device) const
{
   // 1W-Kernel device name format : ff-iiiiiiiiiiii, with :
   // - ff : family (1 byte)
   // - iiiiiiiiiiii : id (6 bytes)

   // Retrieve family from the first 2 chars
   device.family=ToFamily(deviceName.substr(0,2));

    // Device Id (6 chars after '.')
   std_to_upper(deviceName.substr(3,3+6*2),device.devid);

   // Filename (full path)
   device.filename=Wire1_Base_Dir;
   device.filename+="/" + deviceName;
}
Example #6
0
   boost::shared_ptr<device::IDevice> CEngine::createDevice(const std::string& line) const
   {
      // 1W-Kernel device name format : ff-iiiiiiiiiiii, with :
      // - ff : family (1 byte)
      // - iiiiiiiiiiii : id (6 bytes)

      // Retrieve family from the first 2 chars
      EOneWireFamily family = ToFamily(line.substr(0, 2));

      // Device Id (6 chars after '.')
      std::string id = line.substr(3, 6 * 2);
      boost::to_upper(id);

      // Device path
      boost::filesystem::path devicePath = m_configuration->getKernelMountPoint() / line;

      return createDevice(family, id, devicePath);
   }