Rx data From Grupo ELECTROGENO.


osbox68

Recommended Posts

:unsure:

Dear, I have to next query, I have a remote computer when an alarm which sends a string, is possible receives this string by the DAQ Factory and if possible how they can do. the string to receive the stx-number-code-crc-etx example: 02-03-00-00-23-45-03 the string always starts with 02 (STX and ends with 03 (ETX) atte.

Luis Mu

Link to comment
Share on other sites

Certainly, the easiest way is to simply have a sequence sit and read the port. Assuming you've created a serial device that is getting this info (use the serial Monitor to confirm), the script might look like this:

while(1)
   try
	  private string datain = device.myDevice.read(1)
	  if (asc(datain) == 2) // beginning of frame
		 datain += device.myDevice.read(6) // assuming frame size is always 7 characters
		 // datain now has the info.  Parse it out and do what you want with it...
		 // .....
	  endif
   catch()
	  delay(0.1)
   endcatch
endwhile

As a side note for those designing their own protocols, I don't particularly like protocols that use STX and ETX but then allow those characters in the frame. You can't then simply read until you hit an STX, then read until you hit ETX. DF1 uses a confusing double character thing to keep a true end of frame character separate from one that is used in the data, but its really quite annoying. Modbus actually provides a simple, effective and reliable template, namely providing the length of the packet as one of the first bytes of the packet.

Link to comment
Share on other sites

Thank you very much for your reply, I have little doubt that you code. put in the answer where you write in the part of sequences, or where it generates the serial device (Configuration Protocol).

With respect to the protocol you is right, so I changed to one that begins with cr-lf + 6 bytes long. dspido me waiting for your prompt response.

Link to comment
Share on other sites

Dear We will then send my application where I put some things from your example and take the serialguide.pdf other works for me but only for the first record, I inform you, I have a card arduino one Conet to a generator where I read signs and charge using the protocol outlined in the serialguide.pdf p. 16. if you could help would be very grateful

:unsure:

Nac.ctl

Link to comment
Share on other sites

Despite what the guide says, I recommend using a sequence like what I sent instead of trying to do your own protocol. Doing your own protocol should be done after you have figured out the communications, and then only if you need to reuse it across multiple documents.

Protocols also are not stored in the .ctl document, so the file you posted is basically empty.

Link to comment
Share on other sites

Dear try placing the code you sent me a script but not work, then sent him what I did, also sent a screenshot of the screen where you can see the inserted coding sequence and the parrt below shows the sttring that is coming, I say goodbye atte expecting your prompt response.

Luis Munoz

pd: for the zip file i use de Total Commander.

Nac2.ctl

Fondo_Azeotech.zip

Link to comment
Share on other sites

The code I posted doesn't work because the data you are receiving doesn't look like what you described. From your screen shot it looks like 9 ASCII characters followed by a CRLF pair. In that case, just do:

while(1)
   try
	  private string datain = device.myDevice.readUntil(10)
	  private data = asca(datain) // convert to array of bytes
	  Valor1 = (data[0] - 30) + (data[1] - 30)
	  // etc...
   catch()
	  delay(0.1)
   endcatch
endwhile

Personally, I don't think you are processing the data coming in correctly either, but I can't say for sure. Out of your reading of 105566123 what do you expect the result to be for Valor1, 2, 3?

Link to comment
Share on other sites

First of all Thanks for your replies, I inform you that my part that my apliaciones communication is running smoothly, thank you for your suggestion to modify the communication protocol, which changes as a guide tells him that says "Serial and Ethernet Comunication Guide "on page. 16, then send you the pantalla_1 2 screen shot shows the register read operation and the string that is coming, and the above shows as pantalla_2 configure. atte firing me, until the next thanking his good disposition

PD : Remeber for ZIP files i use the Total Commander.

Luis Mu

pantalla_1.zip

pantalla_2.zip

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.