How to convert integer/number into hex data - serial-port

I am building an Android app that interacts with devices that are connected via USB ports. I am trying to figure out the formula or looking for online too to convert the number into the correct hex data for product ID and vendor ID.
Here is my data:
9025 = 0x2341 (Arduino vendor id)
5824 = 0x16C0
1155 = 0x0483
What I am looking for is a formula or tool (online) that will convert the values on the left hand side into the right-hand side. I used this, https://codebeautify.org/string-hex-converter. But it is not giving me the expected result.

Here you go:
Serial.println(9025,HEX);

Related

Using OpenStreetMapX to create a powergrid graph network

I want to find out a few things about OpenStreetMapX which from what I understand works well with transportation-based networks. I am wondering if it's also possible to use this package along with lightgraphs.jl to create a power grid network. In my case, I have filtered some power grid data using osmosis (a piece of software that allows filtering OpenStreetMap data based on a tag)
I want to know whether it is relevant to use OpenStreetMapX for this kind of data (power grid)?
using OpenStreetMapX
# Load power data for Germany
deData = get_map_data("D:/PowerGridNetwork/data/germany/de_power_160718.osm")
# Get roadways (which I believe has the meta data for edges)
deData.roadways
I ended up with metadata for power as well as roads, which I am wondering, how it came in the first place. Since I filtered only the power data.
The next question I have is, does deData.e returns an adjacency list?. Since what I am really after is creating a MetaGraph with nodes and edges with their respective properties.
Any ideas?
Thanks in advance

Is it possible to aggregate data with varying nesting depth in Grafana?

I have data in Grafana with different nesting depths. It looks like this (the nesting depth differs depending on the message type):
foo.<host>.type.<type-id>
foo.<host>.type.<type-id>.<subtype-id>
foo.<host>.type.<type-id>.<subtype-id>.<more-nesting>
...
The <host> field can be the IP of the server sending the data and <type-id> is the type of message that it handled. There are quite a lot of message types but for the visualization I am only interested in the first level of <type-id> aggregated over all hosts.
For example, if I have this data:
foo.ip1.type.type1 = 3
foo.ip1.type.type2.subtype1 = 5
foo.ip2.type.type1 = 4
foo.ip2.type.type2.subtype1 = 9
foo.ip2.type.type2.subtype2 = 13
I would rather see it like this:
foo.*.type.type1 = 7 (3+4)
foo.*.type.type2 = 27 (5+9+13)
Then it would be easier to produce a graph where you can see which types of messages are most frequent.
I have not found a way to express that in Grafana. The only option that I see is to create a graph by manually creating queries for each message type. If there were only a handful of types that would be OK, but in my example, the number of types is quite high and even worse, they can change over time. When new message types are added, I would like to see them without having to change the graph.
Does Grafana support to aggregate the data in such a way? Can it visualize the data aggregated by one node and while summing up everything that comes after the node (like the --max-depth option in the Unix du command)?
I am not very experienced with Grafana, but I am starting to believe this functionality is not supported. Not sure whether Grafana allows to preprocess the data, but if the data could be transformed to
foo.ip1.type.type1 = 3
foo.ip1.type.type2_subtype1 = 5
foo.ip2.type.type1 = 4
foo.ip2.type.type2_subtype1 = 9
foo.ip2.type.type2_subtype2 = 13
it would also be valid workaround as the number of subtypes in very low in my data (often there is even only one subtype).
I think the groupByNode function might be useful to you. By doing something like:
groupByNode(foo.ip1.type.*.*,3,"sumSeries")
You'll need to repeat this for each level of nesting. Hope that helps.
More information is available here:
http://graphite.readthedocs.io/en/latest/functions.html#graphite.render.functions.groupByNode
If you want to do it the way you alluded to in your example you could use aliasSub

AudioBuffer's "getChannelData()" equivalent for MediaStream (or MediaStreamAudioSourceNode)?

I use AudioContext's decodeAudioData on an mp3 file, which gives me an AudioBuffer. With this audio buffer, I go on to draw a waveform of this mp3 file on a canvas using the data returned by getChannelData().
Now I want to use the same code to draw a waveform of the audio data of a MediaStream, which means I need the same kind of input/data. I know a MediaStream contains real time information, but there must be a way to access each new data from the MediaStream as
a Float32Array containing the PCM data
which is what the AudioBuffer's getChannelData returns.
I tried to wrap the MediaStream with a MediaStreamAudioSourceNode and feed it into an AnalyserNode to use getFloatFrequencyData() (which returns a Float32Array), but I can tell the data is different from the data I get from getChannelData(). Maybe it isn't "PCM" data? How can I get "PCM" data?
Hopefully this is clear. Thanks for the help!
First, a note that AnalyserNode only samples the data occasionally, but won't process all of it. I think that matches your scenario well, but just know that if you need all the data (like, you're buffering up the audio), you will need to use ScriptProcessor instead today.
Presuming you just want samples of the data, you can use AnalyserNode, but you should call getFloatTimeDomainData(), not getFloatFrequencyData(). That will give you the PCM data (FrequencyData is giving you the FFT of the PCM data).
create MediaStreamDestination with audiocontext and then new MediaRecorder from the stream,
var options = {mimeType: 'audio/webm;codecs=pcm'};
mediaRecorder = new MediaRecorder(stream, options);

How to GS1 parse 01.10.17.21?

I have some products which have 2d GS1 bar codes on them. Most have the format 01.17.10 which is GTIN.Expiry Date.Lot Number.
This makes sense as 01 and 17 are fixed length, so can be parsed easily, just by splitting the string in the appropriate place.
However, I also have some in the format 01.10.17.21 (GTIN.Lot.Expiry.Serial Number) which doesn't make sense because Lot and Serial number are variable length, meaning I cannot use position to decode the various elements. Also, I cannot search for the AIs as they could legitimately appear in the data.
It seems that I've no way of reliably decoding this format. Am I missing something?
Thanks!
According to the GS 1 website, "More than one AI can be carried in one bar code. When this happens, AIs with a fixed length data content (e.g., SSCC has a fixed length of 18 digits) are placed at the beginning and AI with variable lengths are placed at the end. If more than one variable length AI is placed in one bar code, then a special "function" character is used to tell the scanner system when one ends and the other one starts."
So it looks like they intend for you to order your AIs with the fixed width identifiers first. Then separate the variable-width fields with a function character, which it, appears is FNC1, but implementing that that will depend on the barcode symbology you are using, It may be different between DataMatrix, Code 128 and QR Code for example.

QR codes - same URL - different image - why?

Why do some QR codes look different when using the same URL?
There are 40 Versions (sizes) of QR Codes, 4 error correction levels and 8 masking possibilities giving a total of 1280 possible QR codes for any given input.
Typically the version is chosen based on the amount of data to be stored and the mask is chosen to produce the best image in terms of readability. The error correction level is chosen by the encoder based on how much data might need to be recovered...
Choosing a different error correction level will result in a different image. The higher the level, better the chances it can recover from unreadable data.
http://en.wikipedia.org/wiki/QR_code#Storage

Resources