Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Serial string carriage return 1

Status
Not open for further replies.

roadrash

Programmer
Joined
May 17, 2005
Messages
12
Location
US
greeting all,
i have a perl script that net telnets to a serial device, which waits for data to insert into a DB.

I have been battling this serial device, which is programmed to send a carriage return at the end of each string. which it is (i telnet to it and watch the strings and it does do a return). the manual states that the carriage return has a control function of ^M and a decimal value of 013.

my code is (pretty much trying anything now):
$conn->waitfor(String => '/\xd\015\013\/');
which has had no effect what so ever, sits and waits for something but definitelly not what i am trying to find.

if i change it to (it sends a coma delimited list):
$conn->waitfor(String => ',');
then it loops through the string and inserts each individual data bit. which would be great, but i want the whole string inserted as 1 data value (eventually i will be creating an array of the list to insert into individual collumns, just need to get this part working).

i am a beginner here with perl, so any advice would be greatly appreciated!!!!

sean
 
The decimal for CR is NOT \013 it is 13.
\013 is a way of specifying OCTAL and therefore is equivilant to decimal 11.
To match a carriage return you should need only "\r".
your \015 is correct but it is in a regex with other components that are not correct and consequently will fail.
Try replacing your string with "\r" and see what happens.


Trojan.
 
thanx trojan,
with our other scales the \r has been working great, but for some odd reason this one scale is giving us heartache.

i have even gotten to the point where i am looking for any RE associated with ascii

$conn->waitfor(String => '/[:ascii:]/');

thought about trying:

$conn->waitfor(String => '/\p{IsAscii}/');

also, any thoughts?

thanx
sean
 
in a follow up here is what i have found. in outputing the string to a log (when looping through with just looking for ',' this popped up! ^MSIZEDIST.
^M would be the end of the string and SIZEDIST is the start of the new string. once i get it figured out how to search for ^M i think things will kick right along.
sean
 
fixed, changed to
$conn->waitfor('/[\015\013]/');

and it is now inserting data.

next on the list is to have it grab the string after '/[\015\013]/' and not before.

sean
 
programmed scale to send LF and now everything is working properly.

thanx
sean
 
a star for your efforts and for keeping us posted on your progress :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top