contiki/examples/ipv6/rpl-collect/udp-sink.c file function "tcpiphandler" is not being called for z1 motes in Cooja Simulator - iot

I am trying to extract the sequence number for each packet of all the Z1 motes in my simulation. The problem is that, the function (tcpiphaandler in udp-sink.c) does not get called but the nodes are sending packets to each other in the simulation.
I have tried to print my name (using printf command) under the "tcpiphandler" function to check if it works or not and unfortunately it does nothing.

Related

Lua script read from serial port in OpenWRT

I have Openwrt router with Arduino connected via USB FTDI adapter.
Serial port is /dev/ttyUSB0
Arduino code prints some data:
First part of data printed with delay via command print(), for example:
Serial.begin(9600);
Serial.print(var1);
delay(1000);
Serial.print(var2);
delay(1000);
Serial.print(var3);
delay(1000);
And second part printed with println() command:
Serial.println("");
Serial.println(var4);
Serial.println(var5);
Serial.println(var6);
So when I open Serial port in terminal I can see something like this:
1
then timeout in 1 sec, then
1 2
next timeout. and then
1 2 3
last timeout and
1 2 3
4
5
6
It works in Terminal program and in console in OpenWRT, for example screen /dev/ttyUSB0
I need make a Lua script that will read Serial port and print the data in the same way. I have a simple script, but it doesn't work as expected.
rserial=io.open("/dev/ttyUSB0","r")
while true do
chain = nil
while chain==nil do
chain=rserial:read();
print(chain)
end
end
it shows all data at once.
it doesn't show first 3 vars one by one with delays.
Seems it is because of rserial:read() - it will read until it receives a newline character.
It stated in similar question:
How to read from a serial port in lua
I tried to run this command as was advised there:
stty -F /dev/ttyUSB0 -icanon
but it doesn't help and I don't understand why.
Is it the way to fix this behavior via stty?
or I definitely need to use another Serial libs for Lua script?
All of these libs seems pretty outdated for now and I don't want to use outdated stuff..
From the Lua Reference Manual:
When called without formats, it uses a default format that reads the
next line (see below).
A new line is anything in the buffer until the next newline character.
So as long as you don't send a newline character Lua will wait one as it has been told by calling read()
Once a newline character is received you will be prompted any other character in that line.
Terminal programs usually update every byte to show what they receive in "real-time".
So if you want to have the same behaviour you may not use read() without any arguments.
Use read(1) to read every single byte without waiting for anything else.

Wrong analog output using PCF8591 on Android Things

Note: Since the most logical cause of malfunction is that my component is faulty I have ordered a few more. Will test on them and let you know the result.
I am expanding an existing driver for the PCF8591 Analog to Digital converter, here's the Pcf8591 class in github.
Reading analog inputs works fine, but I have a strange problem when trying to write the output.
To test the driver I have a potentiometer connected to input channel 2, then I write that value to the analog output and then connect the analog output to the input 3.
The analog value only changes from 20 to around 75 for a value write from 0 to 255. I don't know if I am missing something or maybe my component is defective.
I am doing it the way it is specified by the spec sheet and also in the same way I've seen some drivers for Arduino doing it.
This is how I am writing the analog value:
byte[] data = {0x40, // Control code for writing analog value
(byte) (value)}; // Analog value
mI2cDevice.write(data, 2);
I'll appreciate if someone else with this component can try and see if writing the analog value works for them.
In theory the analog output goes from AGND to VREF and I am assuming the board I have have them linked to GND and VCC. I am using this board:

Get network interface in Wireshark Lua dissector

I'm writing a Wireshark dissector in Lua. Is there a way to get the network interface the current frame was received on/transmitted from within the dissector?
There is a frame field called frame.interface_id, available since Wireshark 1.8.0 according to the Wireshark Display Filter Reference page, which should give you the ID of the interface. The ID seems to match the enumeration given in the results of dumpcap -D (or tshark -D) if you subtract 1 from the enumeration. In other words, both dumpcap and tshark count interfaces starting with 1 in the respective -D outputs, while Wireshark seems to start counting from 0. This inconsistency seems like a bug to me and I would suggest filing a Wireshark bug report against this inconsistent behavior.
EDIT (since it seems impossible to format this in a coherent way using comments):
To access the field, you would use a field extractor, see: https://www.wireshark.org/docs/wsdg_html_chunked/lua_module_Field.html
For example:
local fe_interface_id = Field.new("frame.interface_id")
function foo.dissector(buffer, pinfo, tree)
local f_interface_id = fe_interface_id()
pinfo.cols.info:append(", Interface ID=" .. tostring(f_interface_id))
end

FSK demodulation with GNU Radio

I'm trying to demodulate a signal using GNU Radio Companion. The signal is FSK (Frequency-shift keying), with mark and space frequencies at 1200 and 2200 Hz, respectively.
The data in the signal text data generated by a device called GeoStamp Audio. The device generates audio of GPS data fed into it in real time, and it can also decode that audio. I have the decoded text version of the audio for reference.
I have set up a flow graph in GNU Radio (see below), and it runs without error, but with all the variations I've tried, I still can't get the data.
The output of the flow graph should be binary (1s and 0s) that I can later convert to normal text, right?
Is it correct to feed in a wav audio file the way I am?
How can I recover the data from the demodulated signal -- am I missing something in my flow graph?
This is a FFT plot of the wav audio file before demodulation:
This is the result of the scope sink after demodulation (maybe looks promising?):
UPDATE (August 2, 2016): I'm still working on this problem (occasionally), and unfortunately still cannot retrieve the data. The result is a promising-looking string of 1's and 0's, but nothing intelligible.
If anyone has suggestions for figuring out the settings on the Polyphase Clock Sync or Clock Recovery MM blocks, or the gain on the Quad Demod block, I would greatly appreciate it.
Here is one version of an updated flow graph based on Marcus's answer (also trying other versions with polyphase clock recovery):
However, I'm still unable to recover data that makes any sense. The result is a long string of 1's and 0's, but not the right ones. I've tried tweaking nearly all the settings in all the blocks. I thought maybe the clock recovery was off, but I've tried a wide range of values with no improvement.
So, at first sight, my approach here would look something like:
What happens here is that we take the input, shift it in frequency domain so that mark and space are at +-500 Hz, and then use quadrature demod.
"Logically", we can then just make a "sign decision". I'll share the configuration of the Xlating FIR here:
Notice that the signal is first shifted so that the center frequency (middle between 2200 and 1200 Hz) ends up at 0Hz, and then filtered by a low pass (gain = 1.0, Stopband starts at 1 kHz, Passband ends at 1 kHz - 400 Hz = 600 Hz). At this point, the actual bandwidth that's still present in the signal is much lower than the sample rate, so you might also just downsample without losses (set decimation to something higher, e.g. 16), but for the sake of analysis, we won't do that.
The time sink should now show better values. Have a look at the edges; they are probably not extremely steep. For clock sync I'd hence recommend to just go and try the polyphase clock recovery instead of Müller & Mueller; chosing about any "somewhat round" pulse shape could work.
For fun and giggles, I clicked together a quick demo demod (GRC here):
which shows:

ESP8266 flash write cycle limit

I have a problem with ESP8266 12E and 12F series about write commands. When I need to write data to the flash in ESP8266 it only allows to around 6800 times with (w+) command. I am using both integer and float and lastest and previous firmwares but nothing changes. An example simple code is below. With ESPlorer I run the codes and when both test1 lua and test2 lua reaches to 3400 file system starts to reset the module. I only activate module by formatting it. If I use just one file it reaches around 6800 cycle of writing. With (a+) command and 2 files I only managed to write up to total 13600 number somehow. Then again a format is needed. I do not how to erase and where to erase flash form lua file.
Any help would be appreciated.
test=0
tmr.alarm(6, 100, 1, function()
file.open("test1.lua","w+")
file.writeline(test)
file.close()
file.open("test2.lua","w+")
file.writeline(test)
file.close()
test=test+1
end)

Resources