EzDevInfo.com

hal

application/hal builder / formatter for PHP 5.4+

Is there a Linux radio standard?

We're about to embark upon implementing a device running Linux that (among other things) will be attached to a software defined FM/AM radio that can also receive RDS data describing playlists and other such stuff. It's a relatively stupid device that mostly contains a DSP or two that act as tuners and otherwise does very little processing of the signal.

I was thinking that kernel drivers for the device and then a userland hardware abstraction layer that provided a standardized interface and abstracted away the details of exactly when the RDS data was received and dealt with error handling and all the other messy stuff. Is there already a userland layer like this? It would be nice to either avoid making it at all, or make our stuff plug-compatible with something that already exists so we could use other projects for the radio UI if we wanted.


Source: (StackOverflow)

Get the form factor of a Linux machine

Is there a "usual" way to detect whether a is a laptop, desktop, tablet, phone, embedded device, server, virtual machine and so on without the use of HAL?

In the past this information could be snagged from smbios.chassis.type, but as HAL is now deprecated in most Linux distributions I need to get access to this some other way. I can't see anything obvious in dmidecode.


Source: (StackOverflow)

Advertisements

Find a HAL object based on /dev node path

I'm using python-dbus to interface with HAL, and I need to find a device's UDI based on it's path in the /dev hierarchy.

So given a path such as /dev/sdb, I want to get a value back like /org/freedesktop/Hal/devices/usb_device_10.


Source: (StackOverflow)

STM32F4 UART HAL Driver

I'm trying to figure out how to use this new HAL driver. I want to receive data using the HAL_UART_Receive_IT() which sets up the device to run an interrupt function when data is received.

Problem is that you have to specify the length of data to read before the interrupt triggers. I plan on sending console like commands of varying length so can't have a fixed length. I assume the only way to do this would be to read single characters at a time and build up a separate string.

The HAL driver seems to have a problem where if you set the HAL_UART_Receive_IT() to receive x number of characters, and then try to send more than x characters, there will be an error.

Currently I have no idea if I'm going about it the right way, any ideas?


Source: (StackOverflow)

Creating a network driver

I'm pretty much a total idiot when it comes to writing hardware drivers, however I'm fairly decent at C/C++.

I have a for fun project I want to work on that is attempting to use a device as a network tether proxy.

What I would like to do is create a driver that appears to be a network driver to windows, but actually sends/receives through a USB port connected to another device.

I have a pretty good idea of what needs to be implemented, but I don't know quite where to start looking for research info.

Any pointers?


Source: (StackOverflow)

DirectX HAL specification

Where can one find the DirectX HAL specification?

Taking this diagram to be correct

alt text

Then all GPU vendors have to write their device drivers such that they speak to the HAL.

Where is the HAL specified? How does MSFT adjust or update the HAL? When does the HAL change? If the HAL changes does the world break or the sky fall?


Source: (StackOverflow)

How to change HAL links format using Spring HATEOAS

I'm building a Spring REST application using Spring HATEOAS (0.16.0.RELEASE) and I'd like the JSON links output to look like:

_links: {
   self: {
     href: "https://<ip>/api/policies/321"
   }
}

while it renders like:

   "links":
      [{
       "rel":"self",
       "href":"http://<ip>/api/policies/321"
      }]

I'm using HATEOAS Resource and ResourceAssembler.

Why do I get this format instead of the other? How can I change it?


Source: (StackOverflow)

When do hal properties get updated

I'm calling GetProperty on a org.freedesktop.Hal.Device from my handler during a PropertyNotified signal. I'm only calling GetProperty on properties that have been added or changed.

When I call GetProperty during property adds, I'm getting a org.freedesktop.Hal.NoSuchProperty exception. I'm also worried that during changes, I'm getting the old values.

When should I be calling GetProperty? What race conditions are involved?


Source: (StackOverflow)

Flatten a nested object to map its properties to the target object

I'm trying to use AutoMapper to map classes like this:

class FooDTO
{
    public int X { get; set; }
    public EmbeddedDTO Embedded { get; set; }
    public class EmbeddedDTO
    {
        public BarDTO Y { get; set; }
        public BazDTO Z { get; set; }
    }
}

To classes like this:

class Foo
{
    public int X { get; set; }
    public Bar Y { get; set; }
    public Baz Z { get; set; }
}

(FooDTO is a HAL resource)

I know I can do it by creating the map explicitly like this:

Mapper.CreateMap<FooDTO, Foo>()
      .ForMember(f => f.Y, c => c.MapFrom(f => f.Embedded.Y))
      .ForMember(f => f.Z, c => c.MapFrom(f => f.Embedded.Z));

Or even with a trick like this:

Mapper.CreateMap<FooDTO, Foo>()
      .AfterMap((source, dest) => Mapper.Map(source.Embedded, dest));

But the problem is that I will have many similar HAL resources to map, and I'd rather not have to configure each one separately. I actually have a generic object model that looks like this:

class HalResource
{
    [JsonProperty("_links")]
    public IDictionary<string, HalLink> Links { get; set; }
}

class HalResource<TEmbedded> : HalResource
{
    [JsonProperty("_embedded")]
    public TEmbedded Embedded { get; set; }
}

class HalLink
{
    [JsonProperty("href")]
    public string Href { get; set; }
}

With this model, the FooDTO class is actually declared like this

class FooDTO : HalResource<FooDTO.EmbeddedDTO>
{
    public int X { get; set; }
    public class EmbeddedDTO
    {
        public int Y { get; set; }
        public int Z { get; set; }
    }
}

Is there a way to configure the mapping globally for all classes that inherit HalResource<TEmbedded>, so that the properties of the DTO's Embedded property are mapped directly to the target object? I tried to do it with a custom IObjectMapper, but it proved more challenging than I expected...


Source: (StackOverflow)

libudev advice needed

I am embarking on a programming project that will need to confirm device identity of removable media (e.g. usb thumb drives) before it will go on to do a bunch of other cool stuff.

Some friends of mine pointed me towards using the Serial Number, and preliminary testing using the udevadm command indicates that this should work. I did some additional checking and it appears that if I can get the software working with libudev then it should (minimally) compile on ubuntu, slackware and gentoo, which would be a really nice benefit.

So I used bing to find a tutorial and got the Signal 11 site (http://www.signal11.us/oss/udev/) it's a very well-written tutorial. It actually seems to have everything I need. I download the code. Fix a couple of platform-specific bugs and then compile. BOOM! Gcc compiles without errors. So far so good.

But when I try to run it, it kicks up a couple of bugs, and I realize that I need to read some more tutorials so that I can understand libudev well enough to fix the bugs, and to turn out working software. Problem is that there really ISN'T any other tutorials (that I can find) and the kernel.org site that is the (only known?) site of the library documentation is down after a recent server compromise.

I considered just issuing udevadm directives to system() and then parsing results, but that's a really hackish way to put software together, and I am planning on releasing this to the community when I'm finished writing.

So how best for me to learn libudev??


Source: (StackOverflow)

HAL - how to monitor audio output on a mac

There is an application called wiretap available at
http://www.ambrosiasw.com/utilities/wiretap/

This application can record the system audio. I would like to be able to do the same in my program. Any insights on what I need to do this? I am familiar with Core Audio but havent found anything on how to do this.

would this help getting the answer? I entered the command line: ioreg -w0 -l | grep io |more
this is what I found aboud wiretap....there might be more related info close to where i found it:
+-o com_AmbrosiaSW_AudioSupport <class com_AmbrosiaSW_AudioSupport, registered, matched, active, busy 0, retain 4 >
"CFBundleIdentifier" = "com.AmbrosiaSW.AudioSupport"
"IOMatchCategory" = "com_AmbrosiaSW_AudioSupport"
"version" = 2
"IOClass" = "com_AmbrosiaSW_AudioSupport"
yan-bellavances-mac-mini:~ ybellavance$ ioreg -w0 -l | grep io |more


Source: (StackOverflow)

Disable GNOME's automount with Python

I need to stop GNOME/Nautilus from automagically mounting new devices and partitions as they appear to the system. How can I accomplish this in python?


Source: (StackOverflow)

How to register a custom hydrator in Zend Framework 2?

In an Apigility driven ZF2 application I want to use a custom Hydrator.

Module class

class Module implements ApigilityProviderInterface {
    ...
    public function getServiceConfig() {
        return array(
            'factories' => array(
                ...
                'MyNamespace\\Hydrator\\ProjectHydrator' => function(ServiceManager $serviceManager) {
                    $projectHydrator = new ProjectHydrator();
                    $projectHydrator->setImageService($serviceManager->get('Portfolio\V2\Rest\ImageService'));
                    return $projectHydrator;
                }
            ),
            ...
        );
    }
}

module.config.php

...
'zf-hal' => array(
    'metadata_map' => array(
        ...
        'Portfolio\\V2\\Rest\\Project\\ProjectEntity' => array(
            'entity_identifier_name' => 'id',
            'route_name' => 'portfolio.rest.project',
            'route_identifier_name' => 'id',
            // 'hydrator' => 'Zend\\Stdlib\\Hydrator\\ClassMethods',
            'hydrator' => 'MyNamespace\\Hydrator\\ProjectHydrator',
        ),
        ...
    ),
),
...

It's ignored, when a collection get retrieved, but it's another issue (s. here). When a single entity is required, the hydratin mechanism starts, but it doesn't use my factory, in order to create an instance.

After some debugging I came to this place in the ZF\Hal\Metadata\Metadata#setHydrator(...) code:

if (is_string($hydrator)) {
    if (null !== $this->hydrators
        && $this->hydrators->has($hydrator)
    ) {
        $hydrator = $this->hydrators->get($hydrator);
    } elseif (class_exists($hydrator)) {
        $hydrator = new $hydrator(); // <-- here
    }
}

The custom Hydrator gets created directly. (In my case it causes a fatal error, since it's tried then to execute a method on ProjectHydrator#imageService, that is not set). I took a look at the Metadata#hydrators (of type Zend\Stdlib\Hydrator\HydratorPluginManager) and found only four default invocables, that's why null !== $this->hydrators && $this->hydrators->has($hydrator) is false and a direct instantiating is tried.

So, I guess, I have to register my custom hydrator. Where/how can I do this?


EDIT:

I move the factory code from Module#getServiceConfig() to Module#getHydratorConfig():

public function getHydratorConfig() {
    return array(
        'factories' => array(
            // V2
            'MyNamespace\\Hydrator\\ProjectHydrator' => function(ServiceManager $serviceManager) {
                $projectHydrator = new ProjectHydrator();
                $projectHydrator->setImageService($serviceManager->get('Portfolio\V2\Rest\ImageService'));
                return $projectHydrator;
            }
        ),
    );
}

The same over the config array in the module.config.php (needs an Factory class):

module.config.php

return array(
    ...
    'hydrators' => array(
        'factories' => array(
            'MyNamespace\\Hydrator\\ProjectHydrator' => 'MyNamespace\\Hydrator\\ProjectHydratorFactory',
        ), 
    ),
);

But its ends with an error:

Zend\ServiceManager\Exception\ServiceNotFoundException

File: /var/www/my-project/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:550 Message: Zend\Stdlib\Hydrator\HydratorPluginManager::get was unable to fetch or create an instance for Portfolio\V2\Rest\ImageService


Source: (StackOverflow)

href link retrieves a not paginated json - spring data rest jpa

I've started working on a REST API using Spring. I'm using the tutorial project gs-accessing-data-rest-initial, which is easy to dowload via Spring Tool Suite, in order to get some stuff working as soon as possible.

I've exposed two related entities (aplicacion and registros_app), using PagingAndSortingRepository and annotated both with @RepositoryRestResource, which enables me to expose entities correctly. The result I'm getting when I query on aplicacion is

 **GET http://localhost:8090/aplicacion**
{
  "_links" : {
    "self" : {
      "href" : "http://localhost:8090/aplicacion/{?page,size,sort}",
      "templated" : true
    }
  },
  "_embedded" : {
    "aplicacion" : [ {
      "nombre" : "app1",
      "_links" : {
        "self" : {
          "href" : "http://localhost:8090/aplicacion/2"
        },
        "registrosApp" : {
          "href" : "http://localhost:8090/aplicacion/2/registrosApp"
        },
        "tipoRegistrosApp" : {
          "href" : "http://localhost:8090/aplicacion/2/tipoRegistrosApp"
        }
      }
    }, {
      "nombre" : "app2",
      "_links" : {
        "self" : {
          "href" : "http://localhost:8090/aplicacion/1"
        },
        "registrosApp" : {
          "href" : "http://localhost:8090/aplicacion/1/registrosApp"
        },
        "tipoRegistrosApp" : {
          "href" : "http://localhost:8090/aplicacion/1/tipoRegistrosApp"
        }
      }
    } ]
  },
  "page" : {
    "size" : 20,
    "totalElements" : 2,
    "totalPages" : 1,
    "number" : 0
  }
}

Which is exactly what I've expected to obtain. So, I was expecting to get the same when I navigate to registrosApp, in terms of pagination; however, when I perform a get on any registrosApp link, what I retrieve from the query is

**GET http://localhost:8090/aplicacion/2/registrosApp**

{
  "_embedded" : {
    "registrosapp" : [ {
      "datos" : "{\"FechaInicio\":\"2014-09-16 18:08:44\",\"UsoMemoria\":\"UsedMemory:3 FreeMemory:491 Total Memory:495 Max Memory:989 \",\"InfoPool\":\"Active: 2\"}",
      "fecha_hora" : "2014-09-17T14:04:07.000+0000",
      "codTipoRegistro" : 1,
      "_links" : {
        "self" : {
          "href" : "http://localhost:8090/registrosApp/605"
        },
        "aplicacion" : {
          "href" : "http://localhost:8090/registrosApp/605/aplicacion"
        }
      }
    },{
      "datos" : "{\"FechaInicio\":\"2014-09-16 18:08:44\",\"UsoMemoria\":\"UsedMemory:3 FreeMemory:491 Total Memory:495 Max Memory:989 \",\"InfoPool\":\"Active: 2\"}",
      "fecha_hora" : "2014-09-17T14:04:07.000+0000",
      "codTipoRegistro" : 1,
      "_links" : {
        "self" : {
          "href" : "http://localhost:8090/registrosApp/667"
        },
        "aplicacion" : {
          "href" : "http://localhost:8090/registrosApp/667/aplicacion"
        }
      }
    } ]
  }
}

Which is not actually paginated. I need to get a paginated json when I navigate across links because registrosApp table grows very quickly. ¿What can I do about it?

Here is the code for my registrosApp and aplicacion repository

@RepositoryRestResource(collectionResourceRel = "registrosapp", path = "registrosApp")
public interface RegistrosAppRepository extends PagingAndSortingRepository<RegistrosApp, Long> {

}

@RepositoryRestResource(collectionResourceRel = "aplicacion", path = "aplicacion")
public interface AplicacionRepository extends PagingAndSortingRepository<Aplicacion, Long> {

//List<Person> findByLastName(@Param("name") String name);

}

And those are the entities I've defined

@Entity
@Table(name = "registros_app")
public class RegistrosApp {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private long idRegistrosApp;
    private String datos;
    private Date fecha_hora;
    private long codTipoRegistro;
    public long getCodTipoRegistro() {
        return codTipoRegistro;
    }
    public void setCodTipoRegistro(long codTipoRegistro) {
        this.codTipoRegistro = codTipoRegistro;
    }
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "idAplicacion", nullable = false, insertable = false, updatable = false)
    Aplicacion aplicacion;
    // private long idAplicacion;
    /*
     * public long getRegistros_app() { return idAplicacion; }
     * 
     * public void setRegistros_app(long registros_app) { this.idAplicacion =
     * registros_app; }
     */
    public String getDatos() {
        return datos;
    }
    public void setDatos(String datos) {
        this.datos = datos;
    }
    public Date getFecha_hora() {
        return fecha_hora;
    }
    public void setFecha_hora(Date fecha_hora) {
        this.fecha_hora = fecha_hora;
    }
}

@Entity
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class Aplicacion {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private long aplicacionId;

    private String nombre;
    //relaciones uno a varios
    //relacion con la tabla registros_app
    @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinColumn(name = "idAplicacion", nullable = false)
    private Set<RegistrosApp> registrosApp = null;
    //relacion con la tabla tipo_registro_app
    @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinColumn(name = "idApp", nullable = false)
    private Set<TipoRegistrosApp> tipoRegistrosApp = null;
    public Set<TipoRegistrosApp> getTipoRegistrosApp() {
        return tipoRegistrosApp;
    }
    public void setTipoRegistrosApp(Set<TipoRegistrosApp> tipoRegistrosApp) {
        this.tipoRegistrosApp = tipoRegistrosApp;
    }
    @JsonProperty
    public Set<RegistrosApp> getRegistrosApp() {
        return registrosApp;
    }
    /**
     * Sets list of <code>Address</code>es.
     */
    public void setRegistrosApp(Set<RegistrosApp> rapps) {
        this.registrosApp= rapps;
    }
    @JsonProperty
    public String getNombre() {
        return nombre;
    }
    public void setNombre(String nombre) {
        this.nombre = nombre;
    }
}

You can notice that I have a @onetomany annotation between aplicacion and registrosapp in my entities.

TL;DR When I query directly on registrosapp I get a paginated result as I expect. The problem here is when I navigate between related entities, I'm not getting the pagination information I need. ¿What can I do in order to get pagination when I navigate across entities? Any help with this will be truly appreciated. Thanks in advance.


Source: (StackOverflow)

How can I find mount point of a device in C/C++?

I am using libhal to detect device events. I am able to detect a device added or removed but I can not detect device's mount point. The function libhal_volume_get_mount_point(volume) does not work.

I have a callback function to detect device add:

static void handle_device_added(LibHalContext *ctx, const char *udi) {

    dbus_bool_t is_storage;
    dbus_bool_t is_volume;

    is_storage = libhal_device_query_capability(ctx, udi, "storage", NULL);
    is_volume = libhal_device_query_capability(ctx, udi, "volume", NULL);

    if (is_storage) {
        drive = libhal_drive_from_udi(ctx, udi);

        if (libhal_drive_is_hotpluggable(drive) || libhal_drive_uses_removable_media(drive)) {
            printf("Storage device added %s model %s\n",
                    libhal_drive_get_device_file(drive),
                    libhal_drive_get_model(drive));
        }

        libhal_drive_free(drive);
    }

    if(is_volume) {
        volume = libhal_volume_from_udi(ctx, udi);
        printf("Mount point = %s\n", libhal_volume_get_mount_point(volume));
        libhal_volume_free(volume);
    }
}

libhal_volume_from_udi, returns NULL.

Do you know any suitable way to detect the mount point of a storage device in C?

UPDATE

I have managed to find mount point of the device by searching /etc/mtab but there is still one little problem. I am assuming the device has one partition only.

How can I get the list of the partition on a storage device? So I can found mount points of each.


Source: (StackOverflow)