suidroot / pyUniden

Python Library for the Uniden BCT15X and BCD996P2
GNU General Public License v3.0
11 stars 1 forks source link

Remote Uniden BR330T #1

Open gersmit opened 2 years ago

gersmit commented 2 years ago

@suidroot , Hello Ben,

My name is Ger from the Netherlands. I am very intrested in your scripts for remote Uniden radio scanner. I wonder if it is possible to use my scanner BR330T (UBC3500xlt). When i run the program it is doing nothing. I use a usb cable with the serial inside (attachement) Can you explian to me how to handle. I am using Raspberry pi 3.

When i use your pyuniden init.py then get error ==== RESTART: /home/pi/piscannerwebcontrol/pyUniden/pyuniden/init.py ==== Traceback (most recent call last): File "/home/pi/piscannerwebcontrol/pyUniden/pyuniden/init.py", line 3, in from .pyuniden import * SystemError: Parent module '' not loaded, cannot perform relative import

When i remove the dot . then it runs, but do nothing.

Thanks in advance for answer greetings Ge usbkabel uniden scanner r

suidroot commented 2 years ago

Hello, As for using this code, it is intended to be imported as a module, there are some examples in the utils directory of using the module. I do not know if the BR330T used the method to control and program as the device I've tested it on (BCP996P2). I know a lot of the different Uniden scanners use different AT command sets if not different methods for programming.

gersmit commented 2 years ago

Hi Ben, thanks for the fast answer. It is with the script scanner.py possible to make contact. get error when i use PORT = '/dev/ttyACM0' Traceback (most recent call last): File "/home/pi/.local/lib/python3.5/site-packages/serial/serialposix.py", line 265, in open self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK) FileNotFoundError: [Errno 2] No such file or directory: '/dev/ttyACM0'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/pi/piscannerwebcontrol/pyUniden/utils/scanner.py", line 174, in main() File "/home/pi/piscannerwebcontrol/pyUniden/utils/scanner.py", line 150, in main scanner.openserial(PORT, SPEED) File "/home/pi/piscannerwebcontrol/pyUniden/utils/pyuniden.py", line 58, in openserial rtscts=False, dsrdtr=False) File "/home/pi/.local/lib/python3.5/site-packages/serial/serialutil.py", line 240, in init self.open() File "/home/pi/.local/lib/python3.5/site-packages/serial/serialposix.py", line 268, in open raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg)) serial.serialutil.SerialException: [Errno 2] could not open port /dev/ttyACM0: [Errno 2] No such file or directory: '/dev/ttyACM0'

When i use PORT = '/dev/ttyUSB0' sendcommand: ff ['ff'] Traceback (most recent call last): File "/home/pi/piscannerwebcontrol/pyUniden/utils/scanner.py", line 174, in main() File "/home/pi/piscannerwebcontrol/pyUniden/utils/scanner.py", line 154, in main screenoutput = scanner.getscreen() File "/home/pi/piscannerwebcontrol/pyUniden/utils/pyuniden.py", line 89, in getscreen if displayarray[1] == '011000': IndexError: list index out of range

Do you have a test script only raspberry pi connect to the scanner with serial usb cable? Where can i find the AT commands so i can test. When i can make contact then i have something.

Thanks and gr Ger

suidroot commented 2 years ago

I did a quick search and found the guide for your model, https://www.uniden.info/download/files/BR330T_REMOTE_COMMAND.pdf It looks pretty similar.

I would validate you are using the correct items in /dev you can often see which one is assigned when plugged with the command 'dmesg'. From the output, you sent using "/dev/ttyUSB0" it looks to be the wrong device. Additionally, you will need to make sure the user you are signed in as has permissions to read and write to the device, often you will need to add the user to the 'dialout' group.

gersmit commented 2 years ago

@suidroot Dear Ben,

Thank you for taking the time to explain to me. I have not done serial communication with the RPI before. You gave me good explanation and got all modules working via PORT = 'dev/ttyUSB0'. I have modified many IndexError: list index out of range. Only restserver.py. gives some problems. Is it true that your program can work through the web server?

I get with restserver.py http://0.0.0.0:8080/. How can I set this with the IP address of the RPI on which the program is running? I hope you will provide me with some more information. What is the meaning of all the modules?

Thanks and greetings Ger

gersmit commented 2 years ago

Dear Ben,

One small question: Is it possible to get only the scan details as frequency, and the names of the channels so i can see with one eye witch frequency is talking.

suidroot commented 2 years ago

The rest server when showing 0.0.0.0 listens on any IP address on the Pi and it provides a handful of calls for muting and setting volume. It should be pretty easy to extend for other functions as needed.

I'll look at adding that functionality in the future, please feel free to add and extent functionality through pull requests.

gersmit commented 2 years ago

@gersmit Hi Ben, I've been playing around with the modules again and I'm getting good data out of the BR330T. I'm not a professional python programmer so here's the question. What steps should I take to work via the web server. If I know this I can add some parts myself. Do I not need index.html or anything else?

would love to hear from you again Thanks and regards| Ger

gersmit commented 2 years ago

I get error: http://0.0.0.0:8080/ 192.168.178.101:62489 - - [01/Feb/2022 15:14:23] "HTTP/1.1 GET /" - 404 Not Found

suidroot commented 2 years ago

The restserver.py just has a handful of URLs address developed. For example, to mute the scanner you would access: http://<IP>:8080/mute. From the code here are the other URLs currently built out.

URLS = (
    '/mute', 'mute',
    '/volume/(.*)', 'volume',
    '/pushbutton/(.*)', 'pushbuttons'
)
gersmit commented 2 years ago

I totally get it and it's going to work. Small question: Do you know if it is possible to write to index.html and how to do it?

suidroot commented 2 years ago

It is possible, that script is using the https://webpy.org/ framework. There are a couple of ways to go about having an index.