ASCII to PDU convertion and back

  • Thread starter Thread starter DraguVaso
  • Start date Start date
D

DraguVaso

Hi,

For my SMS-application I need to be able to send characters with accents
(like é and à). But this doesn't seem to work in Text Mode, so i will need
to do it in PDU Mode.

Does anybody has soem converting routines for that in VB.NET? I need my text
to be converted to a PDU-message, and back (for received messages).

Thansk in advance,

Pieter
 
DraguVaso said:
For my SMS-application I need to be able to send characters with accents
(like é and à). But this doesn't seem to work in Text Mode, so i willneed
to do it in PDU Mode.

How did you try to do it in text mode? You'll need to know the encoding
to use, of course. Note that characters with accents in *aren't* part
of ASCII.
Does anybody has soem converting routines for that in VB.NET? I need my text
to be converted to a PDU-message, and back (for received messages).

http://www.dreamfabric.com/sms/ seems to have quite a bit of
information in it...
 
I tryed to set them just in ir, but that didn't work.
for exemple:
AT+GMGS="0486112233"
This is my message with accents éà<Ctrl-Z>

Do you know the way to send the accents in text-mode? I assume it must
exist, but I can't find how :-(

DraguVaso said:
For my SMS-application I need to be able to send characters with accents
(like é and à). But this doesn't seem to work in Text Mode, so i will need
to do it in PDU Mode.

How did you try to do it in text mode? You'll need to know the encoding
to use, of course. Note that characters with accents in *aren't* part
of ASCII.
Does anybody has soem converting routines for that in VB.NET? I need my text
to be converted to a PDU-message, and back (for received messages).

http://www.dreamfabric.com/sms/ seems to have quite a bit of
information in it...
 
DraguVaso said:
I tryed to set them just in ir, but that didn't work.
for exemple:
AT+GMGS="0486112233"
This is my message with accents éà<Ctrl-Z>

Do you know the way to send the accents in text-mode? I assume it must
exist, but I can't find how :-(

Well, what API are you using to submit the text to start with?
 
I'm not using an API: I'm using VB.NET 2005 with the SerialPort-object, if
that is what you mean...

DraguVaso said:
I tryed to set them just in ir, but that didn't work.
for exemple:
AT+GMGS="0486112233"
This is my message with accents éà<Ctrl-Z>

Do you know the way to send the accents in text-mode? I assume it must
exist, but I can't find how :-(

Well, what API are you using to submit the text to start with?
 
DraguVaso said:
I'm not using an API: I'm using VB.NET 2005 with the SerialPort-object, if
that is what you mean...

Well, that *is* using an API. Anyway...

Anyway, how are you then writing the data to the port? Are you writing
a byte array, or a string? Either way, what encoding are you using?
 
I'm really having troubles to udnerstand what you exactly need to know...

I'm writing a string all the time.
Some of my routines:

Public Sub PinInsert(ByVal strPin As String)
ModemStatus = enumModemStatus.PinValidation
WriteToComPort("AT+CPIN=" & strPin & cstCR)
MessageSilent("Inserting the Pin...")
End Sub

Public Sub SetToTextMode()
ModemStatus = enumModemStatus.TextModeValidation
WriteToComPort("AT+CMGF=1" & cstCR)
MessageSilent("Setting to TextMode...")
End Sub

Public Sub WriteToComPort(ByVal strMessage As String)
SerialPort1.Write(strMessage)
End Sub

Public Sub SmsSendNumber(ByVal strNumber As String)
ModemStatus = enumModemStatus.SmsNumberSending
WriteToComPort("AT+CMGS=" & Chr(34) & strNumber & Chr(34) & cstCR)
End Sub

Public Sub SmsSendMessage(ByVal strMessage As String)
ModemStatus = enumModemStatus.SmsMessageSending
WriteToComPort(strMessage & Chr(26))
End Sub


It works really fine with just normal text, but once I begin using accents
the accents don't come through....
strMessage is like this: "hello world" or "érica"
 
DraguVaso said:
I'm really having troubles to udnerstand what you exactly need to know...

Public Sub WriteToComPort(ByVal strMessage As String)
SerialPort1.Write(strMessage)
End Sub

Okay, that's the bit I needed to know - you're using whatever encoding
the SerialPort class is providing by default.

Try changing that to ISO-8859-1:

SerialPort1.Encoding = Encoding.GetEncoding (28591);
 
Thanks, I changed it and tryed to send some messages but I always got this
answer when I got accents in it:

"met accenten hé jà bèkes

OK
"
And not the "+CMGS: " that I normally should receive...

Even messages without accent don't work: there I get this as an answer for
mthe modem:
"zonder accenten

ERROR
"
.... :-/
 
DraguVaso said:
Thanks, I changed it and tryed to send some messages but I always got this
answer when I got accents in it:

"met accenten hé jà bèkes

OK
"
And not the "+CMGS: " that I normally should receive...

Even messages without accent don't work: there I get this as an answer for
mthe modem:
"zonder accenten

ERROR
"

Do you understand those messages? I don't know the language, I'm
afraid.

Messages without accents shouldn't be affected at all. Print out which
encoding the serial port class is using *before* you set it - that
could be useful information.
 
I added three things here:

- The encoding before I change the encoding
- the encoding after the changes
- how I open the port and change the encoding

The "met accenten hé jà bèkes" and the "zonder accenten" are the SMS that I
tryed to send: they are dutch...


Before the SerialPort1.Encoding = System.Text.Encoding.GetEncoding(28591)

?serialport1.Encoding
{System.Text.ASCIIEncoding}
[System.Text.ASCIIEncoding]: {System.Text.ASCIIEncoding}
ASCII: {System.Text.ASCIIEncoding}
asciiEncoding: {System.Text.ASCIIEncoding}
BigEndianUnicode: {System.Text.UnicodeEncoding}
BodyName: "us-ascii"
ChineseHZ: 52936
CodePage: 20127
CodePageASCII: 20127
CodePageBigEndian: 1201
CodePageDefault: 0
CodePageDLLKorean: 20949
CodePageGB2312: 20936
CodePageMacGB2312: 10008
CodePageMacKorean: 10003
CodePageNoMac: 2
CodePageNoOEM: 1
CodePageNoSymbol: 42
CodePageNoThread: 3
CodePageUnicode: 1200
CodePageUTF32: 65005
CodePageUTF32BE: 65006
CodePageUTF7: 65000
CodePageUTF8: 65001
CodePageWindows1252: 1252
dataItem: {System.Globalization.CodePageDataItem}
DecoderFallback: {System.Text.DecoderReplacementFallback}
Default: {System.Text.SBCSCodePageEncoding}
defaultEncoding: {System.Text.SBCSCodePageEncoding}
DuplicateEUCCN: 51936
emptyByteArray: {Length=0}
ENC50229: 50229
EncoderFallback: {System.Text.EncoderReplacementFallback}
EncodingName: "US-ASCII"
encodings: {Length=1}
EUCCN: 936
EUCJP: 51932
EUCKR: 51949
GB18030: 54936
HeaderName: "us-ascii"
InternalSyncObject: {Object}
IsBrowserDisplay: False
IsBrowserSave: False
ISCIIAssemese: 57006
ISCIIBengali: 57003
ISCIIDevanagari: 57002
ISCIIGujarathi: 57010
ISCIIKannada: 57008
ISCIIMalayalam: 57009
ISCIIOriya: 57007
ISCIIPanjabi: 57011
ISCIITamil: 57004
ISCIITelugu: 57005
IsMailNewsDisplay: True
IsMailNewsSave: True
ISO_8859_1: 28591
ISO_8859_8_Visual: 28598
ISO_8859_8I: 38598
ISO2022JP: 50220
ISO2022JPESC: 50221
ISO2022JPSISO: 50222
ISOKorean: 50225
ISOSimplifiedCN: 50227
IsReadOnly: True
IsSingleByte: True
Latin1: {System.Text.Latin1Encoding}
latin1Encoding: {System.Text.Latin1Encoding}
m_codePage: 20127
m_deserializedFromEverett: False
m_isReadOnly: True
MIMECONTF_BROWSER: 2
MIMECONTF_MAIL1
MIMECONTF_SAVABLE_BROWSER: 512
MIMECONTF_SAVABLE_MAIL256
s_InternalSyncObject: {Object}
Unicode: {System.Text.UnicodeEncoding}
unicodeEncoding: {System.Text.UnicodeEncoding}
UTF32: {System.Text.UTF32Encoding}
utf32Encoding: {System.Text.UTF32Encoding}
UTF7: {System.Text.UTF7Encoding}
utf7Encoding: {System.Text.UTF7Encoding}
UTF8: {System.Text.UTF8Encoding}
utf8Encoding: {System.Text.UTF8Encoding}
WebName: "us-ascii"
WindowsCodePage: 1252


After the SerialPort1.Encoding = System.Text.Encoding.GetEncoding(28591)

?serialport1.Encoding
{System.Text.Latin1Encoding}
[System.Text.Latin1Encoding]: {System.Text.Latin1Encoding}
ASCII: {System.Text.ASCIIEncoding}
asciiEncoding: {System.Text.ASCIIEncoding}
BigEndianUnicode: {System.Text.UnicodeEncoding}
BodyName: "iso-8859-1"
ChineseHZ: 52936
CodePage: 28591
CodePageASCII: 20127
CodePageBigEndian: 1201
CodePageDefault: 0
CodePageDLLKorean: 20949
CodePageGB2312: 20936
CodePageMacGB2312: 10008
CodePageMacKorean: 10003
CodePageNoMac: 2
CodePageNoOEM: 1
CodePageNoSymbol: 42
CodePageNoThread: 3
CodePageUnicode: 1200
CodePageUTF32: 65005
CodePageUTF32BE: 65006
CodePageUTF7: 65000
CodePageUTF8: 65001
CodePageWindows1252: 1252
dataItem: {System.Globalization.CodePageDataItem}
DecoderFallback: {System.Text.InternalDecoderBestFitFallback}
Default: {System.Text.SBCSCodePageEncoding}
defaultEncoding: {System.Text.SBCSCodePageEncoding}
DuplicateEUCCN: 51936
emptyByteArray: {Length=0}
ENC50229: 50229
EncoderFallback: {System.Text.InternalEncoderBestFitFallback}
EncodingName: "Western European (ISO)"
encodings: {Length=2}
EUCCN: 936
EUCJP: 51932
EUCKR: 51949
GB18030: 54936
HeaderName: "iso-8859-1"
InternalSyncObject: {Object}
IsBrowserDisplay: True
IsBrowserSave: True
ISCIIAssemese: 57006
ISCIIBengali: 57003
ISCIIDevanagari: 57002
ISCIIGujarathi: 57010
ISCIIKannada: 57008
ISCIIMalayalam: 57009
ISCIIOriya: 57007
ISCIIPanjabi: 57011
ISCIITamil: 57004
ISCIITelugu: 57005
IsMailNewsDisplay: True
IsMailNewsSave: True
ISO_8859_1: 28591
ISO_8859_8_Visual: 28598
ISO_8859_8I: 38598
ISO2022JP: 50220
ISO2022JPESC: 50221
ISO2022JPSISO: 50222
ISOKorean: 50225
ISOSimplifiedCN: 50227
IsReadOnly: True
IsSingleByte: True
Latin1: {System.Text.Latin1Encoding}
latin1Encoding: {System.Text.Latin1Encoding}
m_codePage: 28591
m_deserializedFromEverett: False
m_isReadOnly: True
MIMECONTF_BROWSER: 2
MIMECONTF_MAIL1
MIMECONTF_SAVABLE_BROWSER: 512
MIMECONTF_SAVABLE_MAIL256
s_InternalSyncObject: {Object}
Unicode: {System.Text.UnicodeEncoding}
unicodeEncoding: {System.Text.UnicodeEncoding}
UTF32: {System.Text.UTF32Encoding}
utf32Encoding: {System.Text.UTF32Encoding}
UTF7: {System.Text.UTF7Encoding}
utf7Encoding: {System.Text.UTF7Encoding}
UTF8: {System.Text.UTF8Encoding}
utf8Encoding: {System.Text.UTF8Encoding}
WebName: "iso-8859-1"
WindowsCodePage: 1252


How I open it:
SerialPort1.PortName = strPortName '"COM1"
SerialPort1.BaudRate = intBaudRate '9600
SerialPort1.DataBits = intDataBits '8
SerialPort1.Parity = parParity 'Parity.None
SerialPort1.StopBits = stbStopBits 'StopBits.One
SerialPort1.Handshake = hskHandShake 'Handshake.None
SerialPort1.Open()
SerialPort1.Encoding = System.Text.Encoding.GetEncoding(28591)



DraguVaso said:
Thanks, I changed it and tryed to send some messages but I always got this
answer when I got accents in it:

"met accenten hé jà bèkes

OK
"
And not the "+CMGS: " that I normally should receive...

Even messages without accent don't work: there I get this as an answer for
mthe modem:
"zonder accenten

ERROR
"

Do you understand those messages? I don't know the language, I'm
afraid.

Messages without accents shouldn't be affected at all. Print out which
encoding the serial port class is using *before* you set it - that
could be useful information.
 
DraguVaso said:
I added three things here:

- The encoding before I change the encoding
- the encoding after the changes
- how I open the port and change the encoding

The "met accenten hé jà bèkes" and the "zonder accenten" are the SMS that I
tryed to send: they are dutch...

<snip>

Ah, I see. Well, sending "zonder accenten" should be identical whether
you're using ASCII or ISO-8859-1.

On the other hand, I see you're using an unprintable character at the
end of the text. I'd strongly recommend sending any binary values as
bytes rather than still using the encoding for that.

Given that you're setting it to "text" mode though, I wonder whether
you might not be limited to ASCII anyway - you may need to change
something else to use non-ASCII characters.
 
Given that you're setting it to "text" mode though, I wonder whether
you might not be limited to ASCII anyway - you may need to change
something else to use non-ASCII characters.

err... so trying to change to PDU would be the thing to do... :-/
Althoug I'm looking almost a whole day on that stuff, and I still wasn't
able to send a message with pdu :-(
 
Back
Top