JavaME RaspBerryPi UART can't receive data from RS485 - java-me

I try to connect my raspberry pi (with raspbian weezy) with a strip LED module. To do this, I use the UART connection of RBPi in order to communicate with RS485 strip connection.
My trouble : I can (yes I can) send data but I don't received ACK or anything else. However my strip LED module send data frame to the RBPi (I can see it on oscilloscope).
EDIT :
I think it's due to the following error that appears when the program opened UART connection. NO : The following error is due to an non-user permission
[ERROR] [DAAPI] iso=-1:cannot open /dev/mem
Well, But I don't receive message...
END EDIT
I write the following javaME code to do this :
UARTConfig config = new UARTConfig((int)Integer.valueOf(this.getPortCom()),(int)Integer.valueOf(this.getPortCom()), this.getBaudrate(),
this.getBitsperchar(), this.getUARTParity(), getStopBits(), UARTConfig.FLOWCONTROL_NONE);
this.uart = (UART)DeviceManager.open(config);
InputStream serialInputStream = Channels.newInputStream(uart);
BufferedReader serialBufferedReader = new BufferedReader(new InputStreamReader(serialInputStream));
this.tSerialOutput = new Thread( new SerialWriter( Channels.newOutputStream(uart) ) );
this.tSerialOutput.start();
this.tSerialInput = new Thread( new SerialReader( serialBufferedReader ));
this.tSerialInput.start();
"this" is my class which manage serial communication.
The error message is getting after the "DeviceManager.open"
I have follow the recommendation of the following ticket :
https://community.oracle.com/message/12513726
But it's not really the answer of my issue (I think...)
I have no idea.... So please, help me ^^

First, you must be sure Serial Port is not already used by Linux Console. Here is how to disable this:
Edit /etc/inittab and disable the following line by adding a # character in front of it
T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
then reboot.
If this is still not working, then you may try to execute JavaME runtime with elevated privileges:
sudo ./runSuite.sh <yourapp>
If this is working, there is a permission problem somewhere.
Finally, you should try to get latest version of JavaME (currently, it is 8.1).

Related

zbus connection not displayed in busctl list

I'm using the zbus crate to make a server able to get events from the dbus.
It works well my code (basically the same as the example from the documentation) is able to receive events so it's fine.
I use busctl to send an event like in the example:
busctl --user call org.zbus.MyGreeter /org/zbus/MyGreeter org.zbus.MyGreeter1 SayHello s "Maria"
And my code is able to receive the event with the parameter just fine.
The thing is I'm having some issues with udev and while I was trying to fix it I found some weird things:
If I send an event with another user it fails with Call failed: the name org.zbus.MyGreeter was not provided by any .service files while my program is running
When I do busctl list --acquired I don't see org.zbus.MyGreeter in the result
My question is: is it normal my program does not appear in the busctl list? Am I doing something wrong or do I use the wrong library to do what I want to do?
Ok it seems there are 2 busses and I was not using the system bus.
I had to replace the method session to system to indicates I want my program to run on the system bus.
Like this:
let _ = ConnectionBuilder::system()?
.name("org.zbus.MyGreeter")?
.serve_at("/org/zbus/MyGreeter", greeter)?
.build()
.await?;
Doing this is not enough because my program does not have to permission to create a service on the bus system. So I had to create a file in /usr/share/dbus-1/system.d where I did write the configuration needed.

Getting Data from PolarH10 via BLE

I have been trying to get data from my PolarH10 with my raspberry-pi. I have been successfully getting data through the commandline with bluez, but have been unable to reproduce that in python. I am using pygatt(gatttool bindings) and python3.
I have been closely following the examples provided on bitbucket and was able to detect my device and filter out it's MAC address by filtering it by name. I however was unable to get either of the "reading data asyncronously" examples to work.
#This doesnt work...
req = gattlib.GATTRequester(mymac)
response = gattlib.GATTResponse()
req.read_by_handle_async(0x15, response) # what does the 0x15 mean?
while not response.received():
time.sleep(0.1)
steps = response.received()[0]
...
#This doesn't work either
class NotifyYourName(gattlib.GATTResponse):
def on_response(self, data):
print("your data is: {}".format(data))
response = NotifyYourName()
req = gattlib.GATTRequester(mymac)
req.read_by_handle_async(0x15, response)
while True:
# here, do other interesting things
time.sleep(1)
I don't know and cannot extract from the "documentation(s)" how to subscribe to/read notifications from a characteristic(heart rate) of my sensor(PolarH10). The error I am getting is when calling GATTRequester.connect(True) is
RuntimeError: Channel or attrib not ready.
Please tell me how correctly connect to a BLE device via Python on Debian and how to programatically identify offered services and their characteristics and how to get their notifications asyncronously in python using gattlib(pygatt) or any other library. Thanks!
The answer is: Just use bleak.
I have a device that presents the same behavior. In my case, the problem was that it does not have a channel of type public, I should use random instead (like in gatttool -b BE:BA:CA:FE:BA:BE -I -t random).
Just calling the connect() method with the parameter channel_type to random could fix it:
requester.connect(True, channel_type="random")
PD: Sorry for the late response (maybe it will be helpful to others).

win32_USBDevice is missging from Win32 Classes

I am trying to retrieve PID and VID of a connected USB device. Starting with this line of C# code:
System.Management.ManagementClass USBClass = new ManagementClass("Win32_USBDevice");
Then I got exception "ManagementException not found", Later I run into this link:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa394084(v=vs.85).aspx
It turned out Win32_USBDevice was not on the list at all. Tried Win32_USBController but didn't get what I wanted. Could anyone let me know if there is any substitute class on the list to extract PID and VID of a connected USB device?
Thanks in advance!
Try this:
System.Management.ManagementClass USBClass = new ManagementClass("Win32_USBHub");
Use Win32_PnPEntity. You can get the both the PID and VID of connected USB devices from Win32_PnPEntity by parsing the "PNPDeviceID".
Start with this example: Get List of connected USB Devices

Execute AT commands in J2ME

I want to know how to execute AT commands inside a J2ME application. The approach that I am taking in brief is as below:
First get all the ports that are present in the phone by
String ports = System.getProperty("microedition.commports");
Now just try to write "AT" and wait for the response from each port (YES I said EACH!!!)
try{
commConnection = (CommConnection) Connector.open("comm:" + portsArr[i] + ";baudrate=19200");
} catch (IOException e) {
print("IOException:Port:" + portsArr[i] + "~Mess: " + e.getMessage());
}
Once I get an "OK" from some port I can execute my intended commands in the same way.
I am trying to execute this on two diffrent phones
Nokia SuperNova 7210
ports=USB1
When I try to write to the port nothing happens.
Nokia Xpress music
ports= USB2,COM1,IR1,USB1,BT1,BT2,BT3,BT4,BT5,BT6,BT7,BT8,BT9,BT10,BT11,BT12,BT13,BT14,BT15,BT16,BT17,BT18,BT19,BT20,BT21,BT22,BT23,BT24,BT25,BT26,BT27,BT28,BT29,BT30,BT31,BT32,BT33,BT34,BT35,BT36,BT37,BT38,BT39,BT40,BT41,BT42,BT43,BT44,BT45,BT46,BT47,BT48,BT49,BT50,BT51,BT52,BT53,BT54,BT55,BT56,BT57,BT58,BT59,BT60,BT61,BT62,BT63,BT64
When I try to write to USB2,COM1,BT1 port
IOException:Port:COM1~Mess: SymbianOS error = -1 : General:
System error
IOException:Port:USB1~Mess: SymbianOS error = -21 : General:
System error
IOException:Port:BT1~Mess: SymbianOS error = -44 : General:
System error
Is this a correct approach?
Smslib uses AT commands but I'm not understanding how do they execute AT commands or how they get the port on which to write the AT commands?
If not possible with J2ME I don't mind not writing the execution of AT commands in some other language as long as both are able to communicate and the solution will support a most of the vendors.
Related - https://stackoverflow.com/questions/3803508/can-i-use-at-commands-insider-j2me-app
What you are trying to achieve is absolutely not possible.
Your approach would only work if Java ME provided access to the GSM modem via COMM ports, which it does not!
(I suppose there could possibly be a device somewhere which offers this, anything's possible in Java ME land, but I have never seen or heard of this).
The library you are referring to runs on a PC which has a device connected to it via the COMM port, it does not work in a Java ME context.
I suspect that what you're really trying to do is access the handset's native SMS inbox via a MIDlet. I promise you, there is absolutely no way to do this!
If what you are trying to do is just send an SMS, maybe you can get to it using an APDU. It seems technically possible:
First you will need JSR 177 SATSA-APDU. Check Nokia devices that have support for it at http://www.developer.nokia.com/Community/Wiki/Java_ME_API_support_on_Nokia_devices
Then you will have to create an SMS APDU just like an STK Applet would do. Please check "Sending a message in the PDU mode" at http://www.dreamfabric.com/sms/
I did not try this, but this is the path I would go if I had to. If it does work with you, please share.

nodejs - reading from the serial port

I've been looking around for an answer on this...
Basically, I want to read data from the serial port (in this case, over USB). I've looked into the node-serialport module but it keeps stalling after the first result form the serial port. I expected it to just spit out the data when it received it. It's as if a buffer is filling up and needs to be flushed somehow?
I've slightly modified the code from the demos I found here - https://github.com/voodootikigod/node-serialport/tree/master/tests
Here's my code:
var sys = require("sys"),
repl = require("repl"),
serialPort = require("serialport").SerialPort;
// Create new serialport pointer
var serial = new serialPort("/dev/tty.usbmodem1d11" , { baudrate : 9600 });
// Add data read event listener
serial.on( "data", function( chunk ) {
sys.puts(chunk);
});
serial.on( "error", function( msg ) {
sys.puts("error: " + msg );
});
repl.start( "=>" );
I'm using an Arduino hence the 9600 baudrate.
Any help would be awesome, cheers,
James
Author of node-serialport. I have tracked down the issue and it is due to a compilation issue with IOWatcher in node.js. I have revised the strategy for reading from the serial port and it now should function as designed in all cases. Please ensure you are using node-serialport 0.2.6 and greater.
Now go out and build JS controlled robots!!!
I also experienced problems with the serial port read.
This is due to a bug in node.js v4.7 (see this issue)
However it worked after switching to an older version of Node.js (v4.0).
It might work with versions up to v4.6 also, but I haven't verified that yet.

Resources