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!
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.
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.
Related
I want to read the data generated by USB sound card connected to my RaspberryPi using a C code. The samples should be stored in an array or are written to a csv file.
I am using ALSA library through a function "snd_pcm_readi". Can someone explain how to access the data read by "snd_pcm_readi"?
Or is there a better alternative?
Look at the libusb library, https://libusb.info/
This library gives you simple C functions to find and open the device, and then send and receive data. You may want to do some reading about USB devices.
You may also want to look at udev - you can write a udev rule to symbolically link the desired device to a known filename.
You may need to know the vendor_id and product_id. At the command line, enter lsusb to see the usb devices.
How can I communicate with an mbed LPC1768 using C without using a terminal emulator like minicom or teraterm?
For example if I send an integer from my C code than that led should be turned on.
How can I do this?
Without reading user manual or datasheet you can't do any thing to your board. So just go through it then follow below link for demo application LPC1768 board
1.NXP LPC1768 ARM Cortex-M3 Red Suite Demo
2.LPC1768 ARM Cortex-M3 CrossWorks Demo
3.mbed
4.At github
If you are using linux or osx check out the following answer:
How do I read data from serial port in Linux using C?
You can check your /dev folder and look for a file that is created when you plug your mBed. The file name would be something like /dev/ttyS0. That file represents the communication port, you can read/write that file to receive/send data over serial port.
If you want a cross platform solution try RxTx library for Java.
You can use this library
what it does, is that it initialize UART port which is connected to the debugger on your board and use it as serial input output. so with any hyper terminal of your choice, you can write code to do something if you send certain string of characters or just use original printf when something happens. and it will be printed on your PC screen.
I have just managed to write my first windows driver (havent registered it yet- but i managed to get the things created!).
I wondered if someone can give me a high overview of how I could achieve the following:
I would like to write a driver which will implement some behaviour when a network packet is received by the computer, before windows does what it does with the packet, i'd like to take this data and output it to the console of a C or C++ program.
Lets assume I have a C/C++ program written, which has a console. How does the C/C++ program interact with the driver I wrote which is hooking the network activity? Is it simply some C code which calls my drivers, the function returns the data as an object and then I can use that object to display in the console?
Thank you in advance for any possible replies
You don't need a driver for this task. Use packet sniffer library like PCap (actually you'll need WinPCap). It's really simple to capture packets and print them to console.
Alternative way is raw socket. But desktop Windows (as opposite to Windows Server) limits raw socket functionality.
If you really want a driver, or have a requirement to manipulate or filter packets before they hit the windows network stack you need to look into filter drivers.
This filter driver can then expose a device file on which your user space application can then read/write. The windows DDK contains examples.
I'm desperately looking for some C sample source code that describes how to implement a HID client using Bluez. More specifically, I would like to know how to write an application that sends keyboard inputs over bluetooth to another Linux system. (Really, the fact that the receiver is running Linux/Bluez shouldn't matter.)
-Cheers
hidclient http://anselm.hoffmeister.be/computer/hidclient/index.html.en ?
Shamelessly copying from a previous answer of mine:
Some time ago I found this project:
http://nohands.sourceforge.net/index.html
They emulate a full-blown headset with
audio and keyboard controls on the
Linux bluetooth stack. If they can
emulate something like that, you would
probably be able to emulate something
simpler like a keyboard.
Here is full example apply to keyboard and mouse include get report set report virtual unplug function. the client hid is slave side...
http://fatalfeel.blogspot.tw/2013/09/hid-client-of-bluez.html
and you can refer to bluez/android/hidhost.c(Master side) see how to connect to slave
I am writing a C program in Linux which will read/write to/from a serial port. I know the data that needs to be read and written on the port but I don't have a serial port to currently test this with.
Is there any way to simulate a serial port? Would reading/writing to a file be sufficient? I can have one process write to the file while another process reads that data and writes back other data to the file. Or are there others tools that can be used to simulate a port?
Thanks
Serial ports on Linux are terminal devices. A close simulation is to create a pseudo-terminal pair; the program that normally talks to the serial port is instead told to open the slave side of the pseudo-terminal, and the simulator writes and reads from the master side.
The pty(7) man page has more information.
Despite being an old topic, and my answer is not exactly something the OP was looking for, I decided to share my experience, as someone else might come across it like I did. Instead of straightforward simulation, I used the software called Serial to Ethernet Connector to gain access to the specific device I needed to test the app with. Worked nicely for me.
A character device, even something as simple as normal stdin and stdout should work if you don't care about attributes specific to port devices.