Connecting Raspberry Pi with cumulocity - cumulocity

I've registered my Raspberry Pi device with Cumulocity.
Now I just wanted to switch on/off LED which is connected with Pi through Cumulocity.
Is it possible and if so how to proceed?

I would propose to use the operation c8y_Relay (http://cumulocity.com/guides/reference/sensor-library/) because it is basically this on(off logic and there are already widgets in the UI to trigger the operation (Can be added to dashboards).
On the device side you would first need to add c8y_Relay to the supportedOperations and then implement an OperationExecutor that will handle the operation and switch the LED (assuming you are using the agent from the example repository)

Related

Creating SoftAP using Hostapd

I have a created two different virtual interfaces by using iw utility commands "iw wlan0 interface add p2p0 type managed", i can able to create and configured as SoftAP using hostapd. We can make it that interfaces up and we can able to get the beacon frame also. if do manual hardware reboot sometime the SoftAP name is not discovering in the WIFI scan list but the beacon frame data received in sniffer logs.
If you guys have an idea please suggest to solve this issue.

How to switch between different Kinect V2 connected to single PC?

I have two Kinect V2, connected to two different USB 3.0 ports on a single PC. I know it is not possible to use both based on SDK V2 concurrently, and I know I should get access to the Kinect V2 using this method:
_sensor = KinectSensor.GetDefault();
However, it always returns back one of the sensors as default and it doesn't matter which USB 3.0 port I connect it.
First of all, is there any methods that we can get list of connected Kinect V2 connected to a single PC and turn on that one based on our preferences?
I want to use one of in each time frame, but need to switch between them.
There is a workaround, which is annoying, but seems to work:
You can enable/disable the USB-port/-controller each Kinect is connected to. Disable all ports but the one you need, and KinectSensor.GetDefault(); should give you the correct sensor.
You can do this manually in the device manager. But I'm sure there is also some way to do this automatically in code.
For more details see the thread Connection to multiple Kinect V2, NOT for synchronous acquisition on the Microsoft support forum.
It's possible to use both Kinects at the same time. I have developed an application that uses 2 Kinects, video and skeleton flows from both in the same time. It developed for sdk 1.8.
So, you can get all available ready devices like that:
KinectSensor.KinectSensors.Where(kinect => kinect.Status == KinectStatus.Connected)
Why do you need to switch between them? You may just activate the needed flow from both at one time. In the sdk it says that both Kinects can't work when they are directed to the same object. But it's working. If you want to switch between them like this:
stop flow from first
activate flow from second
goto p.1
It's bad variant because p. 1 and 2 can take about a second time. It's a very slowly.

Raspberry camera error: "mmal: No data received from sensor"

I used successfully my raspberry camera times ago.
Now I tried again to acquire a image with the raspistill -o image.jpg command; the red led on the camera flashes, but I get this error:
mmal: No data received from sensor.
Check all connections, including the Sunny one on the camera board
Of course the camera connections are fine. Is there any other way to check if the camera is still working?
This error usually appears because of a faulty connection with the camera.
I had the exact same problem in different camera+Pi configurations. The following case is what I encountered:
The connector is not correctly inserted either in the camera or in the Pi.
The Sunny connector (the small yellow one on the camera) is not connected well.
(now it gets interesting)
If you often remove and reinsert the camera in the Pi please be sure to remove all power from the Pi. The sensor is very sensitive and a spark on the wrong pin could burn it. (I did this already unfortunately)
This could also trigger a problem with the Pi connector pins. It was somewhat confirmed that for Pi2 the connector may have some bad soldering which could lead to cold contact soldering. You can fix this by using some flux on the pins and then pass the soldering iron hot end over the pins to remake the connection.
I used a longer cable that had both connectors on the same side of the cable. If you connect it like it is you can burn your sensor and the Pi will not start because of the power surge (also the camera gets very hot in this case). DO NOT REMOVE IT from the Pi without removing power before. To a cable like this you have to remove the blue plastic from one end and bend the connector with the contacts on the other side. Insert this end in the camera since this will not be removed/inserted as often as the Pi end.
Make sure that the silver contacts are well inserted into the PCB connector.
(video here)
Also, make sure that the sunny connector is firmly attached.
This fixed it for me.
I was experiencing the same problem too, until I found a solution.
I removed the sunny connector(the yellow thingy below the camera in the board) and fixed it in the same place. The camera is working fine after trying this.
I have got the same issue. I have find out it was a power supply issue.
Try to change your cable and/or your raspberry power supply adaptor.
You check if this is your reason of your problem by typing:
$ dmesg
if you see something like this:
[ 44.152029] Under-voltage detected! (0x00050005)
-> Then replace your power supply! :D
The only fix for me was to purchase a new camera.
No real root causes identified.
My problem was I put the camera in, while the Pi was on. which might
have made the camera shot. i.e the camera module is static sensitive
and it's possible that it's been damaged
Unfortunately if this is the case there's nothing you can realistically do to fix it, just get a replacement.
This specific error shows when another application is using the camera. In my case, it was motion.
It might be possible that the cable is placed the wrong way. I had this problem and after multiple tries I realized that was the problem.

USB device design for an embedded MCU

I am working on a product with an LPC1788 which needs the following USB features:
Firmware download (from host PC to device, not through a USB
key).
File upload (from device to host).
Ideally we'd also be able to get some information from the device like serial number etc.
The device should only work with a custom Windows application, so simply using a mass-storage device as-is will not do. There are quite a lot of data to upload (200MB +), so using USB bulk transfers seem necessary to me.
What is the best way to approach this? I imagine I would need to create some sort of USB composite device(?). However, I was hoping to use nxpUSBlib or winUSB so I don't have to go through the Windows driver validation process.... What are my options? Perhaps there some way to make the mass-storage device invisible for Windows?
Thanks!
Dirk
I think you'll definitely want to go with a vendor specific bulk device and you can easily use WinUSB for all of this. This should be sufficient for everything you've specified here.
For your firmware loader I'd recommend looking at the DFU (device firmware update) specification. You'll probably want make some command for your device that when sent will cause it to reenumerate itself in to DFU mode for update (rather than a composite device that is always exposed - this restricts the issue of the other interface being in use while you're flashing your device). Then you can flash it and reset it so it will reenumerate as your vendor specific bulk device again.
I wouldn't recommend mucking with mass storage, from your requirements it will be better to implement your own protocol and create some application or DLL that consumes the WinUSB API to communicate with your device, including the firmware update.

USB HID device detection

I am trying to access an USB HID device under Ubuntu(kernel-3.0). I want to write a program which could notify me whenever an USB device is attached to the bus i.e is there any event generated whenever an USB device is plugged in which I can monitor. I have looked into DBus and HAL without any success. But I don't want linux to load its current modules(USBHID and HID) when the device is plugged in. I also want to ask if the mentioned modules are also the device drivers used for HID devices.
My sole purpose is to run a script whenever an USB device is plugged into the bus which will indirectly call the above mentioned modules.
I am writing my code in C. I am quite new to linux. So it would be of great help if anyone could point me in the right direction.
Thanks..
The UDisks deamon will send the D-Bus signal "DeviceAdded" when a USB drive is inserted, and probably another "DeviceAdded" for each partition on the drive. If you have automount you would also get a "DeviceChanged" signal when the partition(s) are mounted. You can then query the UDisks interface, as well as individual devices about their properties, for example. You can find more info on the UDisks interface here: http://hal.freedesktop.org/docs/udisks/UDisks.html
One way to get more familiar with what goes on with block devices (or whatever) on D-Bus, is to install and use D-Feet to inspect the bus. UDisks appear on the System bus. You can see what is there and inspect the properties for individual devices as well as the UDisks interface itself.
Another way, which would also allow you to see what signals are transmitted on the bus, is to run dbus-monitor from the command line.