Page 1 of 1

pi-star 4.1.6 command pistar-bmapi fails

Posted: Wed Aug 10, 2022 8:53 am
by DF9FZ
If you try to execute f.ex.

Code: Select all

pistar-bmapi dropdyn 2
an error (see below) occurs.
One reason could be, that due to editing the configuration files with some editor a stray '\r' is at the end of the line (perhaps editor uses DOS and not UNIX mode).
what happens is, that after the DMRID is extracted from a configuration file a carriage return is left at the end of the shell variable 'DMRID'.
With that variable a URL will be constructed which gets a '%0D' (URL encoded \r) added to the DMR-ID which will not be welcomed by the Brandmeister server and generates an error.

Easy to fix in /usr/local/sbin/pistar-bmapi:
Insert after the 'fi' around line 40 a new line with

Code: Select all

DMRID=${DMRID//$'\r'/}
If you want to check, whether you have such an error case, surround this line with echo outputs:

Code: Select all

echo -n $DMRID|hd
DMRID=${DMRID//$'\r'/}
#echo -n $DMRID|hd
and execute the command:

Code: Select all

pistar-bmapi dmrid
If both output lines do not differ and contain digits only, you're not having this problem with stray \r's.

________________________________________________________________________________
The error output of pistar-bmapi looks like that:


Request to BrandMesiter API: Drop all Dynamic TG on TimeSlot 0 for DMR ID xxxxxxxxxx
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.7/json/__init__.py", line 296, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File "/usr/lib/python3.7/json/__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.7/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Answer from BrandMesiter API:

Re: pi-star 4.1.6 command pistar-bmapi fails

Posted: Fri Aug 19, 2022 2:04 pm
by MW0MWZ
Thank you, I have added that to the code revision for today (updating to add support for BM APIv2)

https://github.com/AndyTaylorTweet/Pi-S ... pi#L39-L40