Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to send custom command #879

Closed
szmolnar opened this issue Oct 2, 2016 · 13 comments
Closed

Unable to send custom command #879

szmolnar opened this issue Oct 2, 2016 · 13 comments

Comments

@szmolnar
Copy link

szmolnar commented Oct 2, 2016

Hi there!

Sending a custom command it seems not to work, however the same command using the original version of traccar 3.7 is working properly.

screen shot 2016-10-02 at 19 54 28
screen shot 2016-10-02 at 19 54 37

Log:
2016-10-02 19:54:35 DEBUG: [8F547004: 5072 > 91.87.128.nn]
2016-10-02 19:54:35 WARN: [8F547004] error - unsupported message type: class java.lang.String - IllegalArgumentException (...)
2016-10-02 19:54:35 INFO: [8F547004] disconnected
2016-10-02 19:54:36 INFO: [E4A2F80F] connected
2016-10-02 19:54:36 DEBUG: [E4A2F80F: 5072 < 91.87.128.nn] HEX: 2a545330312c38363833323330323531363639373323

Original traccar log:
2016-10-01 19:09:05 DEBUG: [149567DD: 5072 > 91.87.128.nn] HEX: 2a545330312c56455223
2016-10-01 19:09:06 DEBUG: [149567DD: 5072 < 91.87.128.nn] HEX: 2a545330312c3836383332333032353136343938362c3137303930363031313031362c5645523a312e3030353b312e3130373b31303a30393a31302d31382e30392e313623

Br.
Szabolcs

@vitalidze
Copy link
Owner

It works just fine for me. Why are you setting up command message as HEX string?

Are you sure you are using latest version of the Traccar Web UI Mod?

@szmolnar
Copy link
Author

szmolnar commented Oct 3, 2016

Hi!

I'm using Ulbotech protocol in Bin mode because Text format is not working in some of the reason.
Text format wasn't working on standard Traccar versions like 3.6 or 3.7

When using text mode, the received commands are not processed on the server side.
It looks strange that by setting command to text mode, the traccar log is still showing it as hex.
Ex:
Bin mode:
bin

"
2016-10-03 19:07:02 INFO: [8D8377B5] id: 868323025164986, time: 2016-10-03 19:07:01, lat: 47.49980, lon: 18.74843, speed: 0.0, course: 0.0
2016-10-03 19:07:14 DEBUG: [8FCC7234: 5072 < 91.82.128.74] HEX: f8010108683230251669739f854cc1010e02d31f6e0123696100000000006203040000000004040ac3b5d30506035317f22213100101894bf8
"

Text mode:
text

"
2016-10-03 19:05:00 DEBUG: [8D8377B5: 5072 < 91.82.128.74] HEX: 2a545330312c3836383332333032353136343938362c3137303435393033313031362c4750533a333b4e34372e3439393739393b4531382e3734383432373b303b303b322e30382c5354543a303b322c4d47523a3231363732353938362c4144433a303b31322e37373b313b33392e34353b323b342e30322c4556543a3123
"

So because Text mode was never working for me I thought to use Bin mode.
Traccar is receiving in Bin mode and is processed properly, device is shown on the map etc, I only have problems sending commands to the device.

Also sending command in text are not working.
screen shot 2016-10-03 at 19 19 40
screen shot 2016-10-03 at 19 19 22
screen shot 2016-10-03 at 19 19 11

Regarding your second question I just downloaded the latest version from:
http://myultrashare.appspot.com/s/traccar-web/dev/latest/traccar-web.war

@vitalidze
Copy link
Owner

Text format wasn't working on standard Traccar versions like 3.6 or 3.7

So, have you done any modifications to the original traccar code? From what I can see it should be sending text commands only in standard implementation.

As for the log entries you are showing - they show what your device sends to traccar and not commands send from traccar. I am totally confused now.

@szmolnar
Copy link
Author

szmolnar commented Oct 3, 2016

First of all no, absolutely no mods. Only mod I did is the config file.

((( As for the entries posted in my last post, those are samples of incoming messages, you are right. I only inserted those to show you what I'm receiving in txt or bin modes. I thought it is interesting for you why receiving in text mode isn't working for me.
Sorry getting you confused. )))

Getting back to my original problem You asked me why I'm using hex mode. I got confused and I thought hex mode is not allowed for sending commands. Either way sending command bin or text isn't working for me.
I also tested text mode commands. On my last post the last 3 screenshots are samples for sending a text mode command.
If you want me to run additional tests please let me know!

Am I etering commands in the right way?
Do I ned to add any additional string?
Sending both Hex or Text mode is allowed?

Thanks you!

@vitalidze
Copy link
Owner

Am I etering commands in the right way?
Do I ned to add any additional string?
Sending both Hex or Text mode is allowed?

From my understanding the only custom commands format, which is supported for now is text format. I don't know how it should work in your case and I don't have such device for testing. So, if you are using original 3.7 traccar, is the command sent interpreted correctly on your device? I think it should not.

@szmolnar
Copy link
Author

szmolnar commented Oct 4, 2016

As mentioned earlier yes, custom commands sent in bin format with original Traccar 3.7 are working perfectly.

Sending in text mode it is not working.

@vitalidze
Copy link
Owner

Well, I think you have faced a bug in this project. It needs to be fixed in code. Until then you will not be able to send commands in binary format.

@vitalidze vitalidze added the bug label Oct 5, 2016
@szmolnar
Copy link
Author

szmolnar commented Oct 5, 2016

What do you think when it will be fixed?
At the other hand do you exactly know where the bug is? May I fix it by myself?

Thanks!

@vitalidze
Copy link
Owner

It will not be fixed in nearest future. Maybe within this month. Bug is in DataServiceImpl class. It sends custom command by directly invoking of write method of the ActiveDevice. But instead of this it should be invoking sendCommand as it does for all other commands types. There is one more thing to know - that it may work in 3.7, but most probably it will not work in some previous versions, where sending of CUSTOM commands wasn't implemented on the "backend" side.

@szmolnar
Copy link
Author

szmolnar commented Oct 8, 2016

I haven't spent much time to interpret the code.
You really mean do I only need to replace "write" to "sendCommand" ?

"
Class<?> objectClass = Class.forName("java.lang.Object");
Method sendCommand = activeDevice.getClass().getDeclaredMethod("write", objectClass);
sendCommand.invoke(activeDevice, command.getCommand());
"

@vitalidze
Copy link
Owner

No, I think removing/commenting out whole code in 'if' branch and leaving only 'else' branch should work it out. But I am not sure.

@szmolnar
Copy link
Author

szmolnar commented Oct 9, 2016

Unfortunately it's not working.

vitalidze added a commit that referenced this issue Dec 17, 2016
@vitalidze
Copy link
Owner

Fixed, written news, updated latest and demo versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants