Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix whitespace padding for PWR #136

Merged
merged 1 commit into from
Mar 1, 2024

Conversation

krasoffski
Copy link
Contributor

@krasoffski krasoffski commented Feb 29, 2024

In some cases WSPR does not decode signal power less than 10.
wsprd_utils.c has simple coverter from decimal to string sprintf(cdbm, "%2d", ndbm);. This works without issue for values bigger than 10. On the other side, some station transmit with values less than 10 or oven with 0 dBm power.

Than we use this value like 0 (whitespace with zero) to build request url using %s formatting.
As a result, url contains invalid value like &dbm= 0 and curl cannot perform this request.

Here is simplifies error log.

              Date   Time    SNR     DT       Freq Dr    Call    Loc Pwr
Spot :  2024-02-29 15:14z -14.54  -0.78  14.097040  0  DB1IAT   JN48 00
Decoder thread -- Sending spot using this URL: http://wsprnet.org/post?function=wspr&rcall=SP2RM&rgrid=JO94hj&rqrg=14.097038&date=240229&time=1356&sig=-20&dt=-0.6&tqrg=14.097038&tcall=DB1IAT&tgrid=JN48&dbm= 0&version=rtlsdr-054&mode=2
curl_easy_perform() failed: URL using bad/illegal format or missing URL

I checked that wsprnet.org respets values like &dbm=01 or &dbm=00 without issues, thus I added zero padding.

> curl -X POST 'http://wsprnet.org/post?function=wspr&rcall=EW1IM&rgrid=JO94hj&rqrg=14.097038&date=240229&time=1354&sig=-20&dt=-0.6&tqrg=14.097038&tcall=DB1IAT&tgrid=JN48&dbm=%200&version=rtlsdr-054&mode=2'
<html>

<body>
  1 out of 1 spot(s) added<br>
Processing took 107 milliseconds.<br>
</body>

The second solution is to escape this particular PWR value using curl_easy_escape before formatting (building) url.

@krasoffski
Copy link
Contributor Author

Here is example from wsprnet.org with this fix.
image

@Guenael Guenael merged commit 17502db into Guenael:main Mar 1, 2024
1 check failed
@Guenael
Copy link
Owner

Guenael commented Mar 1, 2024

Hi Yuri,
Thanks for the bug fix, appreciated!
Merged, but I have to fix my pipeline and push a new release.
73, Guenael

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants