RS 232 connected on ASC1 | Thales IoT Developer Community
May 23, 2014 - 12:04pm, 5234 views
Hello,
I have connected one power meter on ASC1 port using RS 232. I write code below to connect meter and read data over using Modbus protocol.
String strCOM = "comm:COM1;baudrate=9600;bitsperchar=8;stopbits=1;parity=none;blocking=off;autocts=off;autorts=off";
commConn = (CommConnection)Connector.open(strCOM);
inStream = commConn.openInputStream();
outStream = commConn.openOutputStream();
byte[] buffer = new byte[]{};
byte[] frame1 = "here Modbus request";
outStream.write(frame1);
outStream.flush();
int available1 = inStream.available();
System.out.println("inStream Available : "+inStream.available());
readBytes = inStream.read(buffer);
System.out.println("Read Integer : "+readBytes +" and Bytes size : "+buffer.length);
While I run application on ESH6 module then Always get response 0 byte.
so My question is how to know meter is connected on ASC1 or not? I mean there is any command to know ASC1 connected to meter.
I want to check my code to send request to meter or not. So I can figer out my code is wrong or module not request to meter.
I have read java_user_guide pdf file. I have write command AT^SCFG? but i can not understand response. see below response.
at^scfg?
^SCFG: "Call/ECC","0"
^SCFG: "GPRS/AutoAttach","enabled"
^SCFG: "Gpio/mode/ASC1","std"
^SCFG: "Gpio/mode/DAI","gpio"
^SCFG: "Gpio/mode/DCD0","std"
^SCFG: "Gpio/mode/DSR0","std"
^SCFG: "Gpio/mode/DTR0","std"
^SCFG: "Gpio/mode/FSR","gpio"
^SCFG: "Gpio/mode/HSIC","rsv"
^SCFG: "Gpio/mode/PULSE","gpio"
^SCFG: "Gpio/mode/PWM","gpio"
^SCFG: "Gpio/mode/RING0","std"
^SCFG: "Gpio/mode/SPI","rsv"
^SCFG: "Gpio/mode/SYNC","gpio"
^SCFG: "Ident/Manufacturer","Cinterion"
^SCFG: "Ident/Product","EHS6"
^SCFG: "MEShutdown/Fso","0"
^SCFG: "MEopMode/SoR","off"
^SCFG: "Radio/Band","511"
^SCFG: "Radio/OutputPowerReduction","4"
^SCFG: "Serial/Interface/Allocation","1","1"
^SCFG: "Serial/USB/DDD","0","0","0409","1E2D","0058","Cinterion Wireless Modules","EHx",""
^SCFG: "Tcp/IRT","3"
^SCFG: "Tcp/MR","10"
^SCFG: "Tcp/OT","6000"
^SCFG: "Tcp/WithURCs","on"
^SCFG: "Trace/Syslog/Otap","0"
^SCFG: "URC/Ringline","local"
^SCFG: "URC/Ringline/ActiveTime","2"
^SCFG: "Userware/Autostart","1"
^SCFG: "Userware/Autostart/Delay","0"
^SCFG: "Userware/DebugInterface","0.0.0.0","0.0.0.0","0"
^SCFG: "Userware/DebugMode","on"
^SCFG: "Userware/Passwd",
^SCFG: "Userware/Stdout","null",,,,"off"
^SCFG: "Userware/Watchdog","0"
Help me Please.
Thank you
Hello,
these lines:
^SCFG: "Gpio/mode/ASC1","std"
^SCFG: "Serial/Interface/Allocation","1","1"
informs that your AT^SCFG configuration is correct.
Please provide the answer to AT&V and AT^SPOW and inform if you're using EHS6 in development setup using DSB or you're using Gemalto Concept Board.
Regards
Jedrzej
Hello,
I am using Gemalto Concept Board.
AT&V
ACTIVE PROFILE:
E1 Q0 V1 X4 &C1 &D2 &S1 \Q3
S0:000 S3:013 S4:010 S5:008 S6:000 S7:060 S8:000 S10:002
+CBST: 7,0,1
+CRLP: 61,61,78,6
+CR: 0
+CRC: 0
+CMGF: 0
+CNMI: 1,0,0,0,0
+CMEE: 0
+CSMS: 0,1,1,1
+CREG: 0,1
+CLIP: 0,2
+COPS: 0,0,"AT&T",2
+CGSMS: 1
OK
AT^SPOW?
^SPOW: 1,0,0
OK
Thank
Durgesh
Hello,
Your software configuration seems to be correct. I can see several potential hardware causes:
1. Swapped RX and TS pins, please double check.
2. Wrong position of onboad serial interface selector. 4th switch must be set to "on". For details refer to chapter 2.3.1 Manual control of SPI/ASC1 sharing and ADC multiplexing of Hardware Interface Description document for Concept Board (available in knowledge base).
3. Maybe your meter uses hardware flow control and needs RTS (for ASC1 marked on board as GPIO18) and CTS (for ASC1 marked as CS) lines to be connected. Remember that if your meter is designed as DTE, you'll have to cross RTS with CTS. Another solution for this issue is to trick the meter by forcing meter's RTS to active state.
Please inform me if you figure something out.
Regards
Jedrzej
Hi,
I work with Durgesh Patel. I checked hardware connections. The connections are swapped. So the meter RX is connected to the TX of ASC1 and the meter TX is connected to the RX of ASC1. Please correct me if I am wrong.
I don't have access to the RTS/CTS/DTE connections of the meter so I assume this is a 3 wire interface and not a 9 wire as you mentioned.
Neel.
Hi,
I took a closer look at your code and found that your declared data buffer's length is 0. There is following note in the documentation of InputStream class: "public int read(byte[] b) (...) If the length of b is zero, then no bytes are read and 0 is returned"
Please write:
byte[] buffer = new byte[< bufLen >];
instead of:
byte[] buffer = new byte[]{};
Regarding hardware connections TX is the output line from the board, RX is the input, so if your meter is designed in the same way, you should have them crossed.
Regards
Jedrzej
Should it not be;
byte[] buffer = new byte[64]; //allocate a byte array of size 64
or
byte[] buffer = {0x00, 0x01, 0x03}; //allocate and initializes a byte array of size 3 with the given values?.
In your post you did not mention the required array dimension.
Yes, of course! That's my mistake, thanks for pointing this out.
Regards
Jedrzej
And to be sure an extra addition :)
readBytes = inStream.read(buffer);
System.out.println("Read Integer : "+readBytes +" and Bytes size : "+buffer.length);
buffer[0 - readBytes] contains the bytes red! So do not use the the buffer.length to check it!
Yes, readBytes is number of bytes red from stream to the buffer whilst buffer.length is number size of the buffer. Single read operation is limited to buffer.length as you can't read more than you can store.
Regards
Jedrzej