java - Receiving HEX messages in Netty -


i'm using netty 4 communicate gps device sends data in hex. problem in netty i'm receiving weird messages($$..0.....@..y..) instead of hex data(00 00 19 40 00 02 79 1d 0d 0a) i'm supposed read. method i'm using handle messages quite simple:

 public void channelread(channelhandlercontext ctx, object msg) {      bytebuf in = (bytebuf) msg;     string message = in.tostring(io.netty.util.charsetutil.us_ascii); } 

and main method:

 public static void main(string args[]) {       eventloopgroup bossgroup = new nioeventloopgroup();     eventloopgroup workergroup = new nioeventloopgroup();      try {         serverbootstrap b = new serverbootstrap();          b.group(bossgroup, workergroup)                 .channel(nioserversocketchannel.class)                 .childhandler(new channelinitializer<socketchannel>() {                     @override                     public void initchannel(socketchannel ch)                             throws exception {                         ch.pipeline().addlast(new gpsmessagehandler());                     }                 })                  .option(channeloption.so_backlog, 128)                 .childoption(channeloption.so_keepalive, true);          channelfuture f = b.bind(port).await();          f.channel().closefuture().syncuninterruptibly();      }      catch (exception e) {     }      {         workergroup.shutdowngracefully();         bossgroup.shutdowngracefully();     }  } 

any appreciated.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -