Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

intToStr sends 0x0 characters as part of the AT command. #10

Open
stephane-chazelas opened this issue Dec 5, 2017 · 0 comments
Open

Comments

@stephane-chazelas
Copy link

When using

echo test | gsmsendsms -C "$service_center" -b 19200 -d "$device" "$mobile_number"

I get a

ME/TA error 'invalid PDU mode parameter' (code 304)

Running it under strace, I see that the ERROR 304 comes in response to:

write(3, "AT+CMGS=18\0\r", 12)    = 12

Note the spurious NUL character there.

This diff:

diff --git a/gsmlib/gsm_util.cc b/gsmlib/gsm_util.cc
index 373592c..f054929 100644
--- a/gsmlib/gsm_util.cc
+++ b/gsmlib/gsm_util.cc
@@ -164,7 +164,7 @@ bool gsmlib::hexToBuf(const std::string &hexString, unsigned char *buf)
 std::string gsmlib::intToStr(int i)
 {
   std::ostringstream os;
-  os << i << std::ends;
+  os << i;
   return os.str();
 }
 

makes that character and the error go away. I don't know enough of C++ to know why that std:ends was there in the first place.

That's tested with the current git HEAD (cd5442d) on Debian unstable (libstdc++6:amd64 7.2.0-16), though the problem was initially seen on Debian jessie (libstdc++6:amd64 4.9.2-10, libgsmme1c2a:amd64 1.10+20120414.gita5e5ae9a-0.2)

It's possible that it is a regression as I didn't get the error on Debian squeeze with the same GSM modem.

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

No branches or pull requests

1 participant