Advertisement
Guest User

Untitled

a guest
Nov 10th, 2014
282
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public Main_routine() {
  2.  
  3.  
  4. try {
  5.  
  6.  
  7. try {
  8. String strCOM = "comm:COM0;blocking=on;baudrate=115200";
  9. commConn = (CommConnection)Connector.open(strCOM);
  10. System.out.println("CommConnection(" + strCOM + ") opened");
  11. System.out.println("Real baud rate: " + commConn.getBaudRate());
  12. inStream = commConn.openInputStream();
  13. outStream = commConn.openOutputStream();
  14. System.out.println("InputStream and OutputStream opened");
  15. } catch(IOException e) {
  16. System.out.println(e);
  17. notifyDestroyed();
  18. }
  19. } catch (Exception ex) {
  20. ex.printStackTrace();
  21. }
  22. }
  23.  
  24.  
  25.  
  26. protected void destroyApp(boolean unconditional)
  27. throws MIDletStateChangeException {
  28. String Response;
  29.  
  30. System.out.println("Closing app");
  31.  
  32. notifyDestroyed();
  33. }
  34.  
  35. protected void pauseApp() {
  36. // TODO Auto-generated method stub
  37. }
  38.  
  39.  
  40. protected void startApp() throws MIDletStateChangeException {
  41. System.out.println("Starting app");
  42. while(1==1)
  43. {
  44. String C1 = "193";
  45. String parameter2 = "17455B0F95";
  46. String parameter3 = "45";
  47. String parameter4 = "5B";
  48. String parameter5 = "0F";
  49. String parameter6 = "95";
  50. byte[] bC1 = C1.getBytes();
  51. byte[] bparameter2 = parameter2.getBytes();
  52. byte[] bparameter3 = parameter3.getBytes();
  53. byte[] bparameter4 = parameter4.getBytes();
  54. byte[] bparameter5 = parameter5.getBytes();
  55. byte[] bparameter6 = parameter6.getBytes();
  56.  
  57.  
  58.  
  59. int ch;
  60. try {
  61. outStream.write(bC1);
  62. Thread.sleep(50);
  63. //outStream.write(bparameter2);
  64. //outStream.write(bparameter3);
  65. //outStream.write(bparameter4);
  66. //outStream.write(bparameter5);
  67. //outStream.write(bparameter6);
  68.  
  69. System.err.println("inStream bytes:" + inStream.available());
  70. if(inStream.available() > 0)
  71. {
  72. String msg = "";
  73. while(inStream.available() > 0)
  74. {
  75. ch = inStream.read();
  76. msg = msg + (char) ch;
  77. }
  78. System.out.println("Serial msg: " + msg);
  79. }
  80. Thread.sleep(50);
  81. } catch (Exception ex) {
  82. ex.printStackTrace();
  83. }
  84.  
  85. }
  86. }
Advertisement
RAW Paste Data Copied
Advertisement