I want to send AT commands in my Android application, but I could not find the right syntax. How can I do this?
The invokeOemRilRequestRaw() and invokeOemRilRequestStrings() methods which have implementations in a number of classes (RIL, PhoneProxy, PhoneBase, and some others) are what you need, but they are not available through the SDK and thus off-limits to us mere mortals.
There is a great review of this in the XDA forum thread:
How to talk to the Modem with AT commands.
That thread show you how to send AT commands (ATC) with a remote
terminal (USB connected to you PC), but it has not yet solved the
problem of how to use a local (phone) terminal to talk to the
phone Modem.
You need a terminal application/program to do any talking to the
modem (remember, its a 2-way communication). So that's why you need
a rooted device, since the root kit usually come with Busybox
(that includes a microcom terminal program). Otherwise you have to
write your own program.
AFAIK. You can disconnect incoming calls in many other and easier
ways than with AT commands.
Use syntax like this and let me know:
echo -e "AT+CFUN=?\r\n" > /dev/ttyUSB0
Related
I have a basic understanding of network programming but i have never had anything to do with USB ports.
This is what i am trying to achieve
I need to write a program in Java, to communicate to a device which is connected to USB port and then later send commands.
I tried terminal as follows earlier but it didn't quite work
ls -l /dev/tty.*
screen /dev/tty.usbserrial-FTYRDSX7 9600
The above didn't work out.
So if someone can just guide with what Java classes i should be looking into and if there are any APIs that should help me get started
Unless you're required to build it from the ground up, use a library such as usb4java (also here). Trying to manage it as a block device and interpreting whatever protocols etc., etc is not worth the effort unless there something very unique to your problem.
So i ended up using jssc which is much easier to use with strait forward syntax and methods
I'm in a project that must perform "tests" on USB Pen Drives.
For that, I'm using a USB Hub (49 port Asic Miner - I'm using it due the number of ports).
I intend to plug 49 USB Pen drives on the HUB and test them using a Linux Java App. The test consists on "check if it is recognized", "storing and deleting data" and "check the size".
My problem is on the first step. If there is any Pen Drive that is not working properly, the system will recognize 48 pen drives, but I'll never know the specific device that is not working.
My question is: Is there any way to know the address (or something like that) of a specific usb port on a usb hub? For example: If I connect just one USB Pen Drive on port "34", my software will know that the device is connected on that specific port.
Thank you very much for your time and for your help!
Use Runtime to execute the Linux command mount. It will list all devices currently mounted, manually or automatically, like:
/dev/sdb5 on /media/xdrive type ext4 (rw,nosuid,nodev,uhelper=udisks)
/dev/sdj1 on /media/Website type vfat (rw,nosuid,nodev,uhelper=udisks,uid=1000,gid=1000,shortname=mixed,dmask=0077,utf8=1,flush)
Here, second line describes the USB stick I have just plugged in (running Ubuntu). It can be easily recognized from the filesystem (vfat, and the hard drive above uses ext4) and it is mounted on /media/Website (because 'Website' is the stick label that has been used when formatting the stick in vfat). It should be trivial to parse the output and locate the mounted sticks (when formatting, I suggest to give the known labels matching the stick numbers).
If needed, you can put more information into the small file directly on the stick.
You can capture the output through the Process.getOutputStream().
When done, you can safely unmount the sticks before pulling them out:
umount /media/Website
You should check these libraries jUSB and usb2java (they are a little out of date though).
However JNI will allow you to create an interface that interacts with different Operating Systems. This would allow you for cross-platform functionality. I'd look into libUSB (because you are looking for Linux) for a good start!
Hope that helps! :)
I have a java application and two different wireless network connections (wifi) on my desktop.
This is a desktop application, not android.
One method of this applicaiton works well with wifi1, second method works well with wifi2.
So far in order to use different methods I have to change wifi settings on my desktop manually.
Is there any way I could change wifi connection setting from the application programmatically ?
Java is a High-Level, Platform-Independent programming language. Network settings, and how you control them will depend on your Operating System, and to my knowledge there is no simple way to expose this in Java.
'
Luckily, some platform-dependent code mixed with Java can help you achieve the result you're after.
The Java
See the Runtime.exec() method, which allows you access to the Windows Command Line or the Mac/Linux Terminal.
The Windows (Adjust for other OS'es)
Now that we have access to the Command Line, we have to run the proper, platform-specific command. See this tutorial for Windows.
Note that it is not a good idea to modify a user's network settings (or anything else external to your application) without their consent.
I want to lookup in my system (using java) for all network cards and network interfaces. So, more exactly, I want to get the whole output from ifconfig command (in Linux) but in Java. I know if I use NetworkInterface.getNetworkInterfaces() will return only configured network interfaces.
A rough approach I found at this link. It is OK, but I'm interested if there are other
possibilities on this.
You can use Runtime.getRuntime().exec("ipconfig") for Windows and Runtime.getRuntime().exec("ifconfig") for linux to get ifconfig result in java
There is no way to get to the gory details here in 100% Java. You can either execute commands or write JNI.
I'm currently doing a project where I have to interact with a circuit I made through the parallel port of a computer. However, my computer doesn't have a parallel port so I borrowed a Parallel to USB adapter cable. The cable didn't come with any drivers, but it's recognized by the device manager as a "USB Printing Support" controller, under the USB section.
It seems that old parallel printers can be plugged in and work properly without any problems. So my question is, if I write a program in Java that tries to interact with a parallel port directly, will it work? And if not, can anyone give me some pointers as to what I need to do to interact with it?
Thanks.
I think you should head toward javax.comm library here.. there is also a different version that is supposed to work better, called librxtx.. take a look here (it's a pluggable replacement for javax.comm)..
I used both of them for an embedded device and they worked great, they manage serial and parallel port.. maybe also usb in your case.
I can't speak for parallel or Java but I've done something similar with serial-via-USB and C#. In that case it was exactly the same as a native controller. YMMV.
As for testing things: get an old dot-matrix printer (and put it in hex dump mode if you really want the nitty-gritty).
If you really want drivers for the thing, find a utility (I think the windows device manager can do it) that gives you the vendor ID and product ID numbers and from those you can look up all kinds of fun stuff (many Linux distributions have a plain text file that maps the numbers to the name of the manufacturer and what not) that plus Google should give you a driver installer.
You need java parallel port drivers which I haven't found for free. You'll have to pay for the driver for Windows.
I think there might be some free drivers if you use Linux.
USB "parallel port" adapters and cables generally aren't. They contain chips that emulate USB printers and send the print data out the parallel port like it might be sent to a similar printer using a parallel (printer) port.
Unless the device you have is actually a printer, there are probably very few (if any) adapters that will work.
There are ways of attaching GPIO "parallel"/bus pins into USB including certain FTDI chips, UARTs and various microcontrollers. If you can write software to use one of these, it could let you drive arbitrary circuits the way olde PC parallel ports were (not through the same MMIO, though).