omega1
omega1

Reputation: 1052

Send Ctrl+Z to serial port via command line

I am trying to send the following to the COM1 serial port via command line using ECHO or similar (I've also tried downloading a small program called serialsend, but I am stuck with how to send the equivalent of CTRL+Z. This is to send a SMS message via a Siemens TC35 GAM module. I am able to do it via Hyperterminal as a test and it works fine, but I cannot figure out how to send the CTRL+Z at the end to confirm the ned of the message.

This is what I have:

AT

AT+CMGF=1

AT+CMSG="+xxxxxxxxxxx"

HELLO

Now, after Hello, which is the message I want to send, I have to send CTRL+Z. But cannot figure out how to do it, I have tried this:

AT

AT+CMGF=1

AT+CMSG="+xxxxxxxxxxx"

HELLO

\x1A

As I read somehwere that this would be the equivalent of doing it, but it hasnt worked.

Can anyone help me with this? I have found solutions, but they are not command line, which is what I need.

I have also tried using this format:

ECHO AT > COM1:

But as I don't know how to send CTRL+Z I don't know if it is working.

Upvotes: 6

Views: 33533

Answers (4)

Petr Simandl
Petr Simandl

Reputation: 1

At my system with usb gsm modem works next script:

$ cat sendsms

    #!/bin/bash
    #usage: sendsms <mobile number> <text to send>
    printf "AT+CMGF=1\r\nAT+CMGS=\"$1\"\r\n$2\x1a" > /dev/ttyUSB3

As you can see, printf sends CTRL + Z as \x1a

Upvotes: 0

user14103702
user14103702

Reputation: 1

type this command Serial.println((char)26); in Arduino code ... one square box will appear on serial monitor. Copy that square and paste in Notepad++. It will be displayed as SUB with black background. wheneever you want to type cntrl+z, just copy this SUB and paste in serial monitor. It works.

Upvotes: 0

Shiridish
Shiridish

Reputation: 4962

Use this:

port.Write(txt_msgbox.Text + char.ConvertFromUtf32(26));

It works :)

Upvotes: 3

user2317447
user2317447

Reputation: 51

I wrote the free command line program SerialSend that you mentioned. Since this question was originally posted, I've added an extra feature that allows arbitrary byte values to be included (in hex format) in the text you're sending via the serial port. For example, to send Ctrl-Z (26 decimal, 0x1A hex), just use the following command:

SerialSend /hex "\x1a"

Port name/number, baudrate, etc can be configured with additional command line arguments. For example,

SerialSend /baudrate 9600 /devnum 2 /hex "\x1a"

For more details, see the SerialSend home page.

Hope that helps!

Ted

Upvotes: 4

Related Questions