OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

USB Lightning Detector only sends Data for few seconds after being powered on

  • Thread starter Thread starter Shyam BHAGAT
  • Start date Start date
S

Shyam BHAGAT

Guest
I am working with an LD-350 Lightning Detector connected via USB to my Ubuntu machine. I've encountered an issue where the data read from the device is only fully detailed and useful immediately after physically removing the power cable of the device and then plugging it back in. The USB cable is seperate from the power cable of the LD-350 and removing and attaching the USB cable does nothing. Attempts to reset the device in my code using RESET<> have not worked.

Problem: When the device is continuously connected, it mostly sends simplistic and repetitive data arrays like [49, 96]. However, right after I reconnect the device, it starts sending complex and detailed data arrays, which is what I need. This detailed output only lasts for a while before reverting to the simplistic output.

Typical Output vs. Desired Output:

Code:
Data read from device:
array('B', [49, 96])
array('B', [49, 96])
array('B', [49, 96])

Desired Output (immediately after repowering the device):

Code:
Data read from device:
array('B', [49, 96, 58, 82, 69, 83, 69, 84, 13, 10, 58, 86, 69, 82, 32, 76, 68, 51, 53, 48, 45, 86, 49, 46, 49, 51, 13, 10])
array('B', [49, 96, 58, 76, 84, 83, 51, 32, 48, 13, 10])
array('B', [49, 96, 58, 87, 73, 77, 76, 73, 44, 50, 53, 52, 44, 52, 49, 55, 44, 49, 50, 52, 46, 53, 42, 53, 66, 13, 10])

Setup:

Code:
OS: Ubuntu 20.04
Language: Python 3.8
Libraries: PyUSB

What I've tried:

Sending a "RESET" command and "RAW 1" command via USB to mimic the reconnection initialization. Monitoring with dmesg, but it only shows the device being recognized without specifics on data handling. Capturing USB packets with Wireshark, but I'm unsure what to look for in the data that could explain or fix the issue. My code:

Code:
import usb.core
import usb.util
import sys
import time

# Setup and find the device
dev = usb.core.find(idVendor=0x0403, idProduct=0xf241)
if dev is None:
    print('Device not found')
    sys.exit(1)

if dev.is_kernel_driver_active(0):
    dev.detach_kernel_driver(0)
dev.set_configuration()

# Send RESET and RAW commands
dev.write(1, 'RESET\r'.encode())
dev.write(1, 'RAW 1\r'.encode())

# Read data from the device
endpoint = dev[0][(0,0)][0]
while True:
    try:
        data = dev.read(endpoint.bEndpointAddress, endpoint.wMaxPacketSize)
        print('Data read from device:', data)
    except usb.core.USBError as e:
        print('Error:', e)

How can I ensure that the device consistently delivers detailed data without needing to physically repower it? Are there specific settings or initialization sequences that typically need to be sent to such USB devices upon connection that I might be missing?
<p>I am working with an LD-350 Lightning Detector connected via USB to my Ubuntu machine. I've encountered an issue where the data read from the device is only fully detailed and useful immediately after physically removing the power cable of the device and then plugging it back in. The USB cable is seperate from the power cable of the LD-350 and removing and attaching the USB cable does nothing. Attempts to reset the device in my code using RESET<> have not worked.</p>
<p>Problem:
When the device is continuously connected, it mostly sends simplistic and repetitive data arrays like [49, 96]. However, right after I reconnect the device, it starts sending complex and detailed data arrays, which is what I need. This detailed output only lasts for a while before reverting to the simplistic output.</p>
<p>Typical Output vs. Desired Output:</p>
<pre><code>Data read from device:
array('B', [49, 96])
array('B', [49, 96])
array('B', [49, 96])
</code></pre>
<p>Desired Output (immediately after repowering the device):</p>
<pre><code>Data read from device:
array('B', [49, 96, 58, 82, 69, 83, 69, 84, 13, 10, 58, 86, 69, 82, 32, 76, 68, 51, 53, 48, 45, 86, 49, 46, 49, 51, 13, 10])
array('B', [49, 96, 58, 76, 84, 83, 51, 32, 48, 13, 10])
array('B', [49, 96, 58, 87, 73, 77, 76, 73, 44, 50, 53, 52, 44, 52, 49, 55, 44, 49, 50, 52, 46, 53, 42, 53, 66, 13, 10])
</code></pre>
<p>Setup:</p>
<pre><code>OS: Ubuntu 20.04
Language: Python 3.8
Libraries: PyUSB
</code></pre>
<p>What I've tried:</p>
<p>Sending a "RESET" command and "RAW 1" command via USB to mimic the reconnection initialization.
Monitoring with dmesg, but it only shows the device being recognized without specifics on data handling.
Capturing USB packets with Wireshark, but I'm unsure what to look for in the data that could explain or fix the issue.
My code:</p>
<pre><code>import usb.core
import usb.util
import sys
import time

# Setup and find the device
dev = usb.core.find(idVendor=0x0403, idProduct=0xf241)
if dev is None:
print('Device not found')
sys.exit(1)

if dev.is_kernel_driver_active(0):
dev.detach_kernel_driver(0)
dev.set_configuration()

# Send RESET and RAW commands
dev.write(1, 'RESET\r'.encode())
dev.write(1, 'RAW 1\r'.encode())

# Read data from the device
endpoint = dev[0][(0,0)][0]
while True:
try:
data = dev.read(endpoint.bEndpointAddress, endpoint.wMaxPacketSize)
print('Data read from device:', data)
except usb.core.USBError as e:
print('Error:', e)
</code></pre>
<p>How can I ensure that the device consistently delivers detailed data without needing to physically repower it? Are there specific settings or initialization sequences that typically need to be sent to such USB devices upon connection that I might be missing?</p>
 

Latest posts

Top