CanMessage createPacket(String s){
  CanMessage m;
  CbusAddress a=new CbusAddress(s);
  if (a.check()) {
    m=a.makeMessage(tc.getCanid());
  }
 else {
    m=new CanMessage(tc.getCanid());
    if (s.charAt(0) == '[') {
      m.setExtended(true);
      int i=s.indexOf(']');
      String h=s.substring(1,i);
      m.setHeader(Integer.parseInt(h,16));
      s=s.substring(i + 1,s.length());
    }
 else     if (s.charAt(0) == '(') {
      int i=s.indexOf(')');
      String h=s.substring(1,i);
      m.setHeader(Integer.parseInt(h,16));
      s=s.substring(i + 1,s.length());
    }
    byte b[]=StringUtil.bytesFromHexString(s);
    m.setNumDataElements(b.length);
    for (int i=0; i < b.length; i++) {
      m.setElement(i,b[i] & 0xff);
    }
  }
  return m;
}

CanMessage createPacket ( String s ) { CanMessage m ; CbusAddress a = new CbusAddress ( s ) ; if ( a . check ( ) ) { m = a . makeMessage ( tc . getCanid ( ) ) ; } else { m = new CanMessage ( tc . getCanid ( ) ) ; if ( s . charAt ( 0 ) == '[' ) { m . setExtended ( true ) ; int i = s . indexOf ( ']' ) ; String h = s . substring ( 1 , i ) ; m . setHeader ( Integer . parseInt ( h , 16 ) ) ; s = s . substring ( i + 1 , s . length ( ) ) ; } else if ( s . charAt ( 0 ) == '(' ) { int i = s . indexOf ( ')' ) ; String h = s . substring ( 1 , i ) ; m . setHeader ( Integer . parseInt ( h , 16 ) ) ; s = s . substring ( i + 1 , s . length ( ) ) ; } byte b [ ] = StringUtil . bytesFromHexString ( s ) ; m . setNumDataElements ( b . length ) ; for ( int i = 0 ; i < b . length ; i ++ ) { m . setElement ( i , b [ i ] & 0xff ) ; } } return m ; }
create a well - formed message from a string string is expected to be space seperated hex bytes or cbusaddress , e . g . : 12 34 56 + n4e1
