Jump to content

Newline Carriage return in string


Nev

Recommended Posts

Hi all, I hope some one can shed some light for me as how to send a carriage return and newline inside a spring that is being sent to a serialport. then read back to browser. The new lines are not working. I've tried \n \r \r\n <br> PHP_EOL. I can get this to work via the echo command but not when sending the spring via serial port.

 

Thanks in anticipation.

 

$serial->sendMessage("The big Brown Fox jumped over the cold lazey dog") . "<br>";
$serial->sendMessage("Message 2"); 
 
 
// Or to read from 
$read = $serial->readPort(); 
echo $read;
echo "line 1" . "<br>";
echo "line 2" . "<br>";
echo "line 3" . "<br>";
 
I get the Result below.
 
The big Brown Fox jumped over the cold lazey dogMessage 2line 1
line 2
line 3
Link to comment
Share on other sites


$serial->sendMessage("The big Brown Fox jumped over the cold lazy dog\n") ;
$serial->sendMessage("Message 2\n");

// Or to read from
$read = $serial->readPort();
echo nl2br($read);
echo "line 1" . "<br>";
echo "line 2" . "<br>";
echo "line 3" . "<br>";
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.