Giter Site home page Giter Site logo

Comments (13)

GideonLeGrange avatar GideonLeGrange commented on August 11, 2024

Hi Moynard

Thank you for pointing this problem out. Il will implement a fix for this and let you know when fixed.

Gideon

from mikrotik-java.

moynard avatar moynard commented on August 11, 2024

your welcome.

from mikrotik-java.

ltardioli avatar ltardioli commented on August 11, 2024

I "solved" this replacing spaces by unicode \u0000

from mikrotik-java.

moynard avatar moynard commented on August 11, 2024

But if you remplace the space with unicode \u0000 the command send ok but in the example con.execute("/interface/gre/set .id=gre1 name=test coment");
the result its "testcomment"

from mikrotik-java.

GideonLeGrange avatar GideonLeGrange commented on August 11, 2024

I'm re-writing the parsing of the command line. A fix for this will be available soon.

from mikrotik-java.

GideonLeGrange avatar GideonLeGrange commented on August 11, 2024

I've fixed this. Please try the latest master and let me know.

from mikrotik-java.

moynard avatar moynard commented on August 11, 2024

im using this library in android. and now with this update didn't work. when i send a parameter in the command.

from mikrotik-java.

GideonLeGrange avatar GideonLeGrange commented on August 11, 2024

Hi

I want to solve this for you.

Can you please send me a bit of sample code and the error message you receive? If you have the full stack trace, that will be helpful.

Gideon

On 21 Apr 2014, at 4:24 PM, moynard [email protected] wrote:

im using this library in android. and now with this update didn't work. when i send a parameter in the command.


Reply to this email directly or view it on GitHub.

from mikrotik-java.

moynard avatar moynard commented on August 11, 2024

the example code is this: i used in a method for execute diferents comands.
List<Map<String, String>> rs= null;
String error ="";
try {
rs=con.execute("interface/bride/disable .id=*6");
} catch (MikrotikApiException e) {
// TODO Auto-generated catch block
e.printStackTrace();
error =e.getMessage();
Log.e("ERROR", e.getMessage());
Map<String, String> errormap = new HashMap();
errormap.put("error", error);
rs = new ArrayList<Map<String,String>>();
rs.add(errormap);
}

    return rs;

i dont recive a error but in the log it apear this and do noting :
04-21 11:25:03.869: D/dalvikvm(7671): GC_FOR_ALLOC freed 19213K, 25% free 12964K/17248K, paused 43ms, total 43ms
04-21 11:25:04.454: D/dalvikvm(7671): GC_FOR_ALLOC freed 1978K, 25% free 13034K/17248K, paused 46ms, total 46ms
04-21 11:25:05.049: D/dalvikvm(7671): GC_FOR_ALLOC freed 1816K, 24% free 13266K/17248K, paused 45ms, total 45ms
04-21 11:25:05.573: D/dalvikvm(7671): GC_FOR_ALLOC freed 1836K, 22% free 13477K/17248K, paused 49ms, total 49ms
04-21 11:25:06.149: D/dalvikvm(7671): GC_FOR_ALLOC freed 1828K, 21% free 13696K/17248K, paused 52ms, total 52ms
04-21 11:25:06.750: D/dalvikvm(7671): GC_FOR_ALLOC freed 1832K, 20% free 13912K/17248K, paused 55ms, total 55ms
04-21 11:25:07.344: D/dalvikvm(7671): GC_FOR_ALLOC freed 1833K, 19% free 14126K/17248K, paused 60ms, total 60ms
04-21 11:25:07.980: D/dalvikvm(7671): GC_FOR_ALLOC freed 1834K, 17% free 14340K/17248K, paused 72ms, total 72ms
04-21 11:25:08.555: D/dalvikvm(7671): GC_FOR_ALLOC freed 1834K, 16% free 14554K/17248K, paused 64ms, total 64ms
04-21 11:25:09.158: D/dalvikvm(7671): GC_FOR_ALLOC freed 1834K, 15% free 14767K/17248K, paused 69ms, total 69ms
04-21 11:25:09.792: D/dalvikvm(7671): GC_FOR_ALLOC freed 1836K, 14% free 14978K/17248K, paused 71ms, total 71ms
04-21 11:25:10.404: D/dalvikvm(7671): GC_FOR_ALLOC freed 1835K, 12% free 15190K/17248K, paused 73ms, total 85ms
04-21 11:25:10.934: D/dalvikvm(7671): GC_FOR_ALLOC freed 1796K, 12% free 15304K/17280K, paused 81ms, total 81ms
04-21 11:25:11.462: D/dalvikvm(7671): GC_FOR_ALLOC freed 1719K, 11% free 15520K/17432K, paused 79ms, total 79ms
04-21 11:25:11.997: D/dalvikvm(7671): GC_FOR_ALLOC freed 1753K, 12% free 15766K/17720K, paused 83ms, total 83ms

from mikrotik-java.

GideonLeGrange avatar GideonLeGrange commented on August 11, 2024

The first problem I see is that your command does not start with a forward slash, as in "/interface/bride/disable". When I write a test program and enter your command as below, I receive the following exception:

Exception in thread "main" me.legrange.mikrotik.impl.ParseException: Expected [/] but found TEXT at position 10
at me.legrange.mikrotik.impl.Parser.expect(Parser.java:167)
at me.legrange.mikrotik.impl.Parser.command(Parser.java:39)
at me.legrange.mikrotik.impl.Parser.parse(Parser.java:22)
at me.legrange.mikrotik.impl.Parser.parse(Parser.java:17)
at me.legrange.mikrotik.impl.ApiConnectionImpl.execute(ApiConnectionImpl.java:94)
at examples.Example6.test(Example6.java:20)
at examples.Example6.main(Example6.java:15)

I'm really confused that you do not receive an error. Is this a function of the Android platform? If you're unsure if the problem is caused by the library, your code or the platform, I would suggest running an example of what you want from your PC, and once that works, put the relevant commands into the Android code.

The second problem I see is "interface/bride" - do you mean "interface/bridge"?

The third problem I see is that I have another bug in the command line scanner :(. I will fix this, test the command you're trying to send, and get back to you.

Gideon

On 21 Apr 2014, at 6:30 PM, moynard [email protected] wrote:

public List> sendComandnewApi(String command,Context context){
List> rs= null;
String error ="";
the example code is this: i used in a method for execute diferents comands.

try {
    rs=con.execute("interface/bride/disable .id=*6");
} catch (MikrotikApiException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    error =e.getMessage();
    Log.e("ERROR", e.getMessage());

Map<String, String> errormap = new HashMap();
errormap.put("error", error);
rs = new ArrayList<Map<String,String>>();
rs.add(errormap);
}

return rs;

}
i dont recive a error but in the log it apear this and do noting :

04-21 11:25:03.869: D/dalvikvm(7671): GC_FOR_ALLOC freed 19213K, 25% free 12964K/17248K, paused 43ms, total 43ms
04-21 11:25:04.454: D/dalvikvm(7671): GC_FOR_ALLOC freed 1978K, 25% free 13034K/17248K, paused 46ms, total 46ms
04-21 11:25:05.049: D/dalvikvm(7671): GC_FOR_ALLOC freed 1816K, 24% free 13266K/17248K, paused 45ms, total 45ms
04-21 11:25:05.573: D/dalvikvm(7671): GC_FOR_ALLOC freed 1836K, 22% free 13477K/17248K, paused 49ms, total 49ms
04-21 11:25:06.149: D/dalvikvm(7671): GC_FOR_ALLOC freed 1828K, 21% free 13696K/17248K, paused 52ms, total 52ms
04-21 11:25:06.750: D/dalvikvm(7671): GC_FOR_ALLOC freed 1832K, 20% free 13912K/17248K, paused 55ms, total 55ms
04-21 11:25:07.344: D/dalvikvm(7671): GC_FOR_ALLOC freed 1833K, 19% free 14126K/17248K, paused 60ms, total 60ms
04-21 11:25:07.980: D/dalvikvm(7671): GC_FOR_ALLOC freed 1834K, 17% free 14340K/17248K, paused 72ms, total 72ms
04-21 11:25:08.555: D/dalvikvm(7671): GC_FOR_ALLOC freed 1834K, 16% free 14554K/17248K, paused 64ms, total 64ms
04-21 11:25:09.158: D/dalvikvm(7671): GC_FOR_ALLOC freed 1834K, 15% free 14767K/17248K, paused 69ms, total 69ms
04-21 11:25:09.792: D/dalvikvm(7671): GC_FOR_ALLOC freed 1836K, 14% free 14978K/17248K, paused 71ms, total 71ms
04-21 11:25:10.404: D/dalvikvm(7671): GC_FOR_ALLOC freed 1835K, 12% free 15190K/17248K, paused 73ms, total 85ms
04-21 11:25:10.934: D/dalvikvm(7671): GC_FOR_ALLOC freed 1796K, 12% free 15304K/17280K, paused 81ms, total 81ms
04-21 11:25:11.462: D/dalvikvm(7671): GC_FOR_ALLOC freed 1719K, 11% free 15520K/17432K, paused 79ms, total 79ms
04-21 11:25:11.997: D/dalvikvm(7671): GC_FOR_ALLOC freed 1753K, 12% free 15766K/17720K, paused 83ms, total 83ms


Reply to this email directly or view it on GitHub.

from mikrotik-java.

moynard avatar moynard commented on August 11, 2024

sorry when i copy paste i change manually to "interface/bride/disable .id=_6" in rs=con.execute(command); but in my code is correct is "/interface/bridge/disable .id=_6". and dont recive any error . only that dalvik messages.

from mikrotik-java.

GideonLeGrange avatar GideonLeGrange commented on August 11, 2024

I have more questions:

  • Does your code hang or freeze, or does it run through but just do nothing?
  • How did you determine that you need to use .id=*6? I possibly don't understand your code but hard coding the value for .id is in my opinion not a good idea at all since it is not guaranteed to remain static.

I much prefer to use the name of the interface. You can use the name you used to create the interface, or the name you found by printing the interface.

Furthermore to help you:

  • I have fixed a small command line scanner bug which affected the processing of .id=*nn. Please pull the latest version and try it now.
  • I have an example below of how I think you should work with .id values. I have tested this on a RB750.
        // Let's create a new bridge. 
        List<Map<String, String>> res = con.execute("/interface/bridge/add name=bridge0");

        // Now find it's .id value. This code is gross in my opinion since we need to 'know' that the value 
        // containing the .id is called "ret"
        String id = res.get(0).get("ret");
        // The print is just so we can see the id received and how it changes over time.
        System.out.println("id = " + id);
        // Let's disable the bridge using the id returned above
        con.execute("/interface/bridge/disable .id=" + id);
        // Let's enable the bridge using it's name rather than id
        con.execute("/interface/bridge/enable .id=bridge0");

Tip: You can make your code easier to cut & paste correctly by using mark down: https://help.github.com/articles/github-flavored-markdown

from mikrotik-java.

moynard avatar moynard commented on August 11, 2024

the code is just a example code. i get the id of getting the /print/interface. i just pull to the latest version and it works fine.

from mikrotik-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.