Closed girs1982 closed 1 year ago
Hi
Sorry, I don't really understand your comment; but it looks like your're having some problems with the Python version (you're using Python3, and the block was developed in Python2).
Please, check the new versions (should be https://foo-manroot.github.io/assets/posts/2018-01-15-gnuradio-ook-transmit/gen_packets_py3.py and/or https://foo-manroot.github.io/assets/posts/2018-01-15-gnuradio-ook-transmit/bruteforce_updated.grc ) and close this issue if it solves your problem
BTW: You should consider cropping your screenshots, there are for example private conversations there that you might not want to make public...
i runn it , now i need done it wait sec
now i need append timers how in it https://github.com/girs1982/Starline_Keeloq_Scaner_Lib (it starline and keeloq arduino lib) i want port it to gnuradio
and preambule , but not fully anderstand this code
https://t.me/King_Grabber
my esp8266 base scaner , now i whant port it
self.rising_timestamps += [ (x + self.time_delta) for x in rising ] self.falling_timestamps += [ (x + self.time_delta) for x in falling ]
# Process the edges when there's at least one burst (rising + falling edges)
if (len (self.rising_timestamps) == len (self.falling_timestamps)
and
len (self.rising_timestamps) >= 1
and
len (self.falling_timestamps) >= 1
):
for rise, fall in zip (self.rising_timestamps, self.falling_timestamps):
diff = fall - rise
if diff < self.threshold:
# Short burst
self.packet.append ("0")
else:
# Long burst
self.packet.append ("1")
i think i need rewrite it
how detect microsecond?
.time_delta -- microsecond , dont fully understand yours logic ,can you help?
i half done but need last rx 1 , modied code for starline , need help it have reactions on starline codes, but it not full done,NEED smal HELP
modifed code --------------------------------------
""" Embedded Python Blocks:
Each this file is saved, GRC will instantiate the first class it finds to get ports and parameters of your block. The arguments to init will be the parameters. All of them are required to have default values! """ import time import numpy as np from gnuradio import gr
class blk (gr.sync_block): """ Block to decode the data on an already squared signal, comprised of 0's and 1's. """
def __init__ (self
, baseband_freq = 600
, sample_rate = 2e6
, sink_file = None): # only default arguments here
"""
Constructor.
Args:
baseband_freq -> Frequency of the baseband signal
sample_rate -> Number of samples per second
sink_file -> File to dump the packets. If it's 'None', prints them on STDOUT
"""
gr.sync_block.__init__(
self,
name = 'OOK to bin sink',
in_sig = [np.float32],
out_sig = []
)
# Number of samples to discern long and short bursts
# sample_rate / baseband_freq = samples_per_period
self.threshold = (sample_rate / baseband_freq) / 2
self.sink_file = sink_file
self.time_delta = 0 # Timer to measure the time between edges
# Lists to store timestamps of rising and falling edges
self.rising_timestamps = []
self.falling_timestamps = []
# Last sample of the previous frame to handle the edge case of one fram ending
# with 0 and the following starting with 1 (thus, not detecting a rising edge)
self.previous_sample = 0
# Counter to determine the end of a packet. If more than (2 * threshold) samples
# are set to 0, the packet is done
self.allzero_count = 0
self.starline_counter_pre = 0
self.starline_counter = 0
self.staline_state = 0
self.packet = [] # List to store the bits of the packet
def dump_packet (self):
"""
Dumps the packet captured on the output file (or STDOUT)
"""
bin_str = str (time.time ()) + ": \t" + "".join (self.packet)
if not self.sink_file:
#print (bin_str)
print("dump")
else:
#print (self.sink_file)
with open (self.sink_file, "a") as f:
f.write (bin_str + "\n")
self.packet = []
def work (self, input_items, *args, **kwargs):
"""
Processing done to retrieve the binary string from the squared signal.
Args:
input_items -> Array with the items from the previous block
Returns:
The length of the processed input array
"""
samples = input_items [0]
diff = np.diff (samples)
#print(diff)
# Gets the indices of rising and falling edges
falling = np.where (diff == -1)[0]
rising = np.where (diff == 1)[0]
#print(falling)
#print(self.time_delta)
bValidPacket = False
# Takes care of an edge at the beginning
if (self.previous_sample != samples [0]):
if samples [0] == 0:
# Falling edge
falling = np.append (0, falling)
else:
# Raising edge
rising = np.append (0, rising)
self.previous_sample = samples [len (samples) - 1]
# If the signal is flat, skips the rest of the processing
if (len (rising) <= 0
and
len (falling) <= 0
):
if samples [0] == 0:
# All 0's
self.allzero_count += len (samples)
if (self.allzero_count > (2 * self.threshold)
and
len (self.packet) > 0
):
# End of a packet
self.dump_packet ()
return len (samples)
else:
# All 1's
self.allzero_count = 0
self.time_delta += len (samples)
return len (samples)
else:
self.allzero_count = 0
self.rising_timestamps += [ (x + self.time_delta) for x in rising ]
self.falling_timestamps += [ (x + self.time_delta) for x in falling ]
# Process the edges when there's at least one burst (rising + falling edges)
if (len (self.rising_timestamps) == len (self.falling_timestamps)
and
len (self.rising_timestamps) >= 1
and
len (self.falling_timestamps) >= 1
):
for rise, fall in zip (self.rising_timestamps, self.falling_timestamps):
diff = fall - rise
bValidPacket = False
#print(diff)#difftime
#print(self.threshold)
if (diff >900 and diff <1100 and self.staline_state ==0):
#print("starline preambule")
self.starline_counter_pre +=1
if self.starline_counter_pre == 6:
print("starline preambule")
self.staline_state =1
elif (self.staline_state==1 and diff >350 and diff <650):
#print("0")
self.packet.append ("B00000000")
bValidPacket = True
elif (self.staline_state==1 and diff >150 and diff <350):
#print("1")
self.packet.append ("B00000001")
bValidPacket = True
if (bValidPacket ==True):
self.starline_counter+=1
if(self.starline_counter==64):
print("getcode")
self.starline_counter=0
self.staline_state=0
self.starline_counter_pre=0
#bin_strstar = str (self.packet)
print(self.packet)
self.packet = []
# if diff < self.threshold:
# Short burst
# self.packet.append ("0")
# else:
# Long burst
# self.packet.append ("1")
# Removes the processed timestamps
self.rising_timestamps.remove (rise)
self.falling_timestamps.remove (fall)
# If both lists are empty, the counter can be resetted
if (len (self.rising_timestamps) == 0
and
len (self.falling_timestamps) == 0
):
self.time_delta = 0
self.time_delta += len (samples)
return len (samples)
Hi
I don't mean to be rude, but I really don't understand you
If you need help (which I might not even be able to provide), you will need to explain yourself better, sorry
Hi
I don't mean to be rude, but I really don't understand you
If you need help (which I might not even be able to provide), you will need to explain yourself better, sorry
Hi i done starline car signal decodder , i have my done arduino library for it, now i whant do it on gnuradio, for level up, and gnuradio library for all, i was take your code and modify , but not all has done, need small help , need know last rx byte ,how it done in yours code? and for understand me, you must see my code and pictures, and see my device on esp8266
video and source https://www.youtube.com/watch?v=YRYe1xse9U8&t=5s in this example cc1101 transmitter ,have on simple transmiter too
Ok, I see... Since you already have it written, I'd suggest to simply use your C code to create your own module, which would be way more easy and efficient than my shitty Python implementation.
You can check these out: https://wiki.gnuradio.org/index.php?title=Creating_Your_First_Block and https://github.com/pcotret/gnuradio-tutorial
Ok, I see... Since you already have it written, I'd suggest to simply use your C code to create your own module, which would be way more easy and efficient than my shitty Python implementation.
You can check these out: https://wiki.gnuradio.org/index.php?title=Creating_Your_First_Block and https://github.com/pcotret/gnuradio-tutorial
but i noob in gnuradio, if you help will be great
have errors need help
i want write my starline decode metods for gnu radio, i have arduino code in my repo, help start yours app, it must will base