I'm trying to get data from OBDII using ionic native bluetooth plugin. However, when i called write method to send the command to the device, no data was returned. The code I used is as below:
readData(device){
this.bluetoothSerial.write('010D').then( (success) => {
alert('Connected to ' + device.name + '. Data reading is successful: ' + new Uint8Array(success));
},
(error) => {
alert('reading failed:' + error );
});
}
The result is shown as below:
My question is: what is the proper way to send command to OBDII to retrieve data using native plugin.
Try with "010D\r" where \r is a carriage return....and read the Hex response.
If you receive NoData means that or the sensor is not in the car or you send an incorrect command.
Remember that the ELM327 can manage one command per time, so you must use something like Queue for manage multi command.
PS:read some documentation about ELM327 and how it manage commands and configuration
Related
I'm implementing call based application using twilio SDK and Ract + Node.js. I have the following requirement.
During an incoming or outgoing (audio) call, a user(any user that’s using the system to call) should be able to see the number pad button.A user should be able to open a popup with the number pad and be able to press numbers. When a user uses the dial pad to press numbers the pressed numbers should be communicated to the other end.
I tried searching the documentation for related methods. found that we can use SendDigits function and implemented some basic logic to trigger when click on a custom button on call screen. but it seems it is not sending the data to other end.
const sendDigit = () => {
console.log("Press 1");
outboundCall.sendDigit('1');
};
if anyone can guide me on how to do this would be a great help. basically, I want to have a dial pad on incoming and outgoing calls and then send press buttons according to the request by other end.
Your code has a function call to sendDigit but the function is called sendDigits.
const sendDigit = () => {
console.log("Press 1");
outboundCall.sendDigits('1');
};
I'm trying to get FX rates in my nodejs server and socke.io emit them to the client, while running MetaTrader Terminal 5 or 4.
So I guess I have to use MQL4/5. I know how the handle the request in my nodejs server. What I dont know is where to write the MQL4 code, what to config in my MetaTrader Terminal.
Lets say I want to send EUR/USD bid rate to my nodejs server everytime it gets changed. How do I achieve that, using MT4/5 and MQL4/5?
My nodejs code:
app.post('/fxroute', (req, res) => {
console.log(req);
let fxRates = req.body // dont know if the payload will be in body
socket.emit('fxRates', fxRates);
});
MQL5 script:
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart(){
string headers;
char data[],
result[];
string str = "data=value"; // POST-data, variables to send
StringToCharArray( str, data );
string b = CharArrayToString( data );
Print( "Test:", b ); // just a test of data, if good ... OK, data was setup correctly.
WebRequest( "POST",
"http://localhost:3000/fxroute",
NULL,
NULL,
3000,
data,
ArraySize( data ),
result,
headers
);
Print( CharArrayToString( result ) ); // see the results
// it returns
// "Results:" No posted data.
}
When I compile and run, I see that it was executed in MT Experts tab, but on my nodejs server, console logs nothing.
Plan of work:
Enable MT4/5 to use {http:|https:} transport-class to selected targets
Create MT4/5 code to execute some kind of {http:|https:} based service
Implement end-to-end logic to be wrapped + hidden inside the dumb http-protocol exchanges
1) Terminal permissions:
Using Terminal->Tools->Options enable [x] "Allow a WebRequest URL" to use a localhost {http:|https:} URL of your choice, matching the nodejs-server setup, in the list
2) WebRequest() code inside event-loop
Given your intentions, create an MQL4 script, using either a built-in IDE F4 or using an external editor of your choice and save the produced .mq4 script file in ~an_MT4_Terminal_Home_Directory/MQL4/Scripts directory
The event-loop is principally your design job:
int start() {
while !isStopped() { // ACK LOOP
if ( RefreshRates() ) { // NEW QUOTE has arrived
... // JOB PROCESS Bid
int aHttpRetCODE = WebRequest(...); // SIG-> NodeJS Server
... // JOB PROCESS Response ( if a bi-directional service )
}
else {
Sleep(...); // NOP on NACK, Terminal has nothing to do
}
}
}
For further details, may like to check my other posts on WebRequest() use-cases and warnings about it's principal limitations.
3) end-to-end logic
Here comes the creme-ala-creme of your design.
Is there any other way?
Yes, there is. That would be the one of my choice - using ZeroMQ or nanomsg on both sides ( MT4/5 Terminal & NodeJS ), thus being able to fully enjoy the freedom of a full-scale distributed systems design ( check the principal aMiniRESPONDER()-prototype example structure for [SIG,MSG] jobs in fully distributed systems ) .
You can also try MetaApi https://metaapi.cloud cloud service which provides REST API and WebSocket API access to both MetaTrader 4 and MetaTrader 5 accounts.
Official REST API documentation: https://metaapi.cloud/docs/client
SDKs: https://metaapi.cloud/sdks (javascript, python and Java SDKs are provided as per April 2021)
It supports reading account information, positions, orders, trade history, receiving quotes, and accessing market data.
The service also provides copy trading API https://metaapi.cloud/docs/copyfactory and API to calculate forex trading metrics on a MetaTrader account https://metaapi.cloud/docs/metastats.
I'm having problems capturing Raw keyboard input in a terminal on windows. This is driving me crazy, because I know that I had implemented this with older versions of nodejs (a year + ago)
Using the latest versions of NodeJS (currently using 4.2.2), capturing input seems buggy.. Unless I am missing something?
What I am running:
stdin = process.stdin;
stdin.on('data', function (data) {
if (data == '\u0003') { process.exit(); }
process.stdout.write('Captured Key : ' + data + "\n");
});
stdin.setEncoding('utf8');
stdin.setRawMode(true);
stdin.resume();
What I am expecting:
Immediately after running, the program should react to whatever key is pressed, and output:
Captured Key : T
Captured Key : E
Captured Key : S
. . . etc
What I am getting:
After running the program, the first keyboard input, acts as if it is NOT captured in Raw and it is captured and displayed on screen.
Then when I press the ENTER key, the text I just typed gets pushed to the handler function, AND THEN the program will accept further input in raw as expected.
Looks like as if the program requires an ENTER keystroke to initiate a proper raw mode input mode?
pic related: I typed TEST (ENTER). Then the program works as expected.
Anyone knows what is this all about? I can't find anything. Also I don't want to use any external libraries. Thanks!
I am trying print the pdf file in my local using printer. This is a code, tried to print.
fs.readFile('documents/AccountStatement.pdf', function(err, data) {
if (err)
throw err;
var printer = ipp.Printer("http://hostname:631/ipp/printer");
var msg = {
"operation-attributes-tag": {
"requesting-user-name": "KUMA1936",
"job-name": "My Test Job",
"document-format": "application/pdf"
},
data: data
};
printer.execute("Print-Job", msg, function(err, res){
console.log(res);
console.log(err);
});
});
In the above code what does printer.execute() method and "Print-Job" parameter. And what does 631 here.When i print the res,its shows
{ version: '1.1',
statusCode: 'server-error-operation-not-supported',
id: 442076,
'operation-attributes-tag':
{ 'attributes-charset': 'utf-8',
'attributes-natural-language': 'en-us' } }
err is null.
You can check the API docs. The first parameter (string) is an operation defined by IPP.
Description about Print-Job operation is given here
3.2.1 Print-Job Operation
This REQUIRED operation allows a client to submit a print job with
only one document and supply the document data (rather than just a
reference to the data). See Section 15 for the suggested steps for
processing create operations and their Operation and Job Template
attributes.
You can see other IPP supported operations here. 631 is the accepted port used for IPP, which uses TCP.
You can check more about the error here, which shows :
13.1.5.2 server-error-operation-not-supported (0x0501)
The IPP object does not support the functionality required to fulfill
the request. This is the appropriate response when the IPP object
does not recognize an operation or is not capable of supporting it.
See sections 3.1.6.1 and 3.1.7.
This means that there is no error in your code. Most likely your printer is not configured or does not support IPP. Last but not the least, the IPP.Printer has to be given the printer IP. So check the IP you are giving is valid (your code shows you gave hostname). From the project page it is given :
To find out if your printer supports IPP:
- Google your printer's specs
- Try: telnet YOUR_PRINTER 631. If it connects, that's a good sign.
- Use the '/examples/findPrinters.js' script.
In my case i just share the printer : (like share with another)
So URL gonna be (you will be found by findPrinters.js)
http://My-Computer-Name.local.:631/printers/my_printer_name
This should be help if your printer donesnt connect (like USB) with your computer. But connect via lan.
Look's like you get an IPP-Version-1.1-Response while sending IPP-2.0.
Try downgrading to 1.1 by using the version-option
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.