Hamra Rehan
Hamra Rehan

Reputation: 189

How to use AT commands in C language

My project consists of a part that has to send sms via GSM modem using AT commands. I have learnt using these commands via hyper terminal and putty. What I want is that how can I use these AT commands in my "C" code built on eclipse. Please guide me!

Upvotes: 1

Views: 3743

Answers (2)

akhil
akhil

Reputation: 732

Consider the device as a file and do I/O operations. We ca send AT commands similar to write data to file.But data must be in mentioned form by the device manufactures.

Upvotes: 1

stevenstevensteven
stevenstevensteven

Reputation: 330

It's going to depend on your OS. I'm assuming the modem is connected to the computer via serial or USB or something like that. On most Unix it would be something like this:

int modem_fd = open("/path/to/modem", O_ASYNC);
char modem_command[] = "ATDT5551234"
write(modem_fd, modem_command, sizeof(modem_command));

You can also get similar functionality with fopen() and fwrite(), which are part of stdio.h.

Upvotes: 1

Related Questions