What does PuTTY send when I press Enter key? - arduino

I am trying desperately to get a Bluetooth dongle working with my Arduino but I can't send it a command that it needs. I can use it when I plug it into my computer via a USB to UART chip and send the command (C) from PuTTY and then press Enter.
The Bluetooth dongle's command sheet says that the command I am trying to send it C<cr> but I can't figure out how to send the proper carriage return character from the Arduino code. I have tried using the Serial.println() function as well as adding the \r character to my current Serial.write("C\r") but neither of those are working.
How can I achieve this?

Interestingly, I can report the opposite on Win 7: PuTTY for me and my embedded project is sending ONLY \r over the COM port. Curious, read: frustratingly unexplainable, but I simply look for either character on the other end of the serial connection.
Then, if you enable "Implicit LF in every CR" under Terminal options it will send both \r\n. Default behaviour seems to be akin to a Commodore machine :D (http://en.wikipedia.org/wiki/Newline). who knew...

Sending CR+LF is possible in modified PuTTY. Source code is available at https://github.com/gniemirowski/putty-crlf and Windows binary at https://www.grzegorz.net/pliki/putty-crlf.zip When you run this version just go to Terminal -> Keyboard and select "CR LF" for "The Enter key" option.

PuTTY emulates xterm which emulates vt100. To have putty send CR/LF when pressing enter, type ESC[20h in putty after connecting to the serial device. This sets VT100 LNM true.
http://vt100.net/docs/vt100-ug/chapter3.html
Line feed/new line New line ESC [20h Line feed ESC [20l

If you watch the ascii table or similar reference you might find interesting: \r ou \x0D
For better understanding, see : http://www.grok2.com/sedfaq6.html

The modified PuTTY is the easiest solution. If you want to stick with the standard PuTTY, there's some other options...
You can send a newline using ctrl+j before pressing enter, but that's a faff.
To automate it, you can use AutoHotKey to change your {ENTER} to ^J{ENTER} when you've got a PuTTY window active:
#if WinActive("ahk_exe putty.exe")
Enter::
SendInput ^J{Enter}
Return
#if
To do this for just one PuTTY window, you can give AHK the name of the window:
#if WinActive("COM8 - PuTTY")
Enter::
SendInput ^J{Enter}
Return
#if

On arduino program, just use Serial.write and both characters codes:
Serial.write(13); // CR
Serial.write(10); // LF
And Avoid Serial.print as it is intended as human readable, so formatted.
references: write print

In standard configuration (on Windows and Linux) if you type "help" and then press enter, the following chain of bytes will appear on the serial port (checked with external connected terminal via RS232, and logic analyzer):
0x68(h) 0x65(e) 0x6c(l) 0x70(p) 0x0d(CR: Carriage Return U+000D)
So it seems like PUTTY puts CR on ENTER (no matter if you are on Linux or Windows).

I'm almost sure that you are looking for the \n new line character.

I tried this very simple code (cr = carriage return)
Serial.write(13);
And because the next "printed" caracters will feed the residual text, it's ok.

Related

Printing by Ethernet to Pacesetter PS125 using DPL, what custom configurations might I need - can't communicate

OK, I have a large asp.net application that prints to Intermec and Zebra printers. I know have to adapt this to print to a Pacesetter Auto Bagger. It is connected through our network and can ping the printer.
Before learning to program DPL I just want to verify that I am able to communicate with the printer. I am using the below code to send a "feed form" command but the printer does nothing. I have tried numerous other simple functions as well.
Does anyone recall any custom configuration (besides static IP) that they may have had to do to print in this fashion?
At this point I have to think this is a printer issue and not my code, as I use it to print to many other devises.
I can find very little support/information online for DPL or this bagger so any help would be great.
Dim IP As String = "XXX.XX.XXX.XXX"
Dim clientSocket As New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
clientSocket.Connect(New IPEndPoint(IPAddress.Parse(IP), 9100))
Dim Label As String = "<STX>F"
clientSocket.Send(Encoding.UTF8.GetBytes(Label))
clientSocket.Close()
I was able to solve this, not the way I wanted but it works.
Instead of sending the raw DPL to the printer I am creating text file and sending that.
Besides the creation of the text file I also changed.
clientSocket.Send(Encoding.UTF8.GetBytes(Label))
To
clientSocket.SendFile("Insert Filepath Here")

Chatset in debug tab of Node-Red

Hi i need know if is possible change the charset of the: "Debug" tab on Node-Red.
Im trying get incoming serial data and show in "Debug" tab, but the input data has rare characters and is not displayed correctly.
Input String example:
"...H.Y.ÝAW.J...~.›..Lé.$...H.Y.ÛGW."
I can send the message to console using:
console.log(msg.payload)
and view this characters, but cannot in debug tab.
Thank's.

HL7 to SQLite with Mirth Connect

I'm trying to build a channel to read an HL7 ADT text file, extract an MRN and write output to a SQLite table (Database Writer).
My SQLite table contains my data but all my PatientIDs are appearing as a concatenated string in one very wide column. As opposed to a PatientID per row/record.
I'm noticing some weird illegal(?) characters in my HL7 file (which come from a Meditech EMR). In QuickViewHL7 they appear in the MSH-22 and MSH-30.
In the VIM editor -
My question is, are these supposed to be delimiters? If so, what are they? Carriage Returns?
I've posted this question on the Mirth Connect forums but seen little but tumbleweeds. I'm hoping someone here might have seen this before and tell me what's going on.
UPDATE: Hex dump suggests it's a 0x7f (0111 1111). This looks like a backspace character. Should I simply strip it or substitute it with something?
This illegal character should be a line feed carriage return to delimit the start of the next HL7 segment.
Using VIM, highlight the illegal character and press 'ga'. This will tell you the hex value of the character. In my case 0xfa (which appears to be a back space!?).
Again in Vim, do a global substitute for a \r
:%s/\%x7f/\r/g
Then save the file.
Everything parses out nicely now.

In asterisk, How can I restrict caller to press particular key as DTMFinstead of all?

I made a call flow using php AGI in asterisk. For getting DTMF from caller, I have user fastpass_get_data() function of AGI. In this function caller can press any key. As and when caller press any key, playing prompt will be stoped.
Now I want that when caller press "1" at that time only that playing prompt will stop. So while prompt file is playing and user press any digit except "1", it will not affect playing file. But if user press "1" playing prompt file file should be stopped and call flow continue onwards.
Thanks !!!
Use streamfile command
stream file Usage: STREAM FILE <filename> <escape digits> [sample offset]
Send the given file, allowing playback to be interrupted by the given digits, if any.
Use double quotes for the digits if you wish none to be permitted.
If sample offset is provided then the audio will seek to sample offset before play starts.
Remember, the file extension must not be included in the filename.
Returns: failure: 200 result=-1 endpos=<sample offset> failure on open: 200 result=0 endpos=0 success: 200 result=0 endpos=<offset> digit pressed: 200 result=<digit> endpos=<offset>
http://www.voip-info.org/wiki/view/stream+file

Unix: what modifier key does "M-" refer to (e.g. M-C)

I'm trying to do a case-sensitive search in Nano. The help menu at the bottom of the screen says I can toggle case-sensitivity by typing M-C.
^G Get Help ^Y First Line ^T Go To Line ^W Beg of Par M-J FullJstify M-B Backwards
^C Cancel ^V Last Line ^R Replace ^O End of Par M-C Case Sens M-R Regexp
I'm not sure how to do this. Does M- refer to a modifier key that should be held while I type C? Or does M- mean I should press some key or key combination before hitting C?
M refers to the meta key, which is not present on most keyboards. (Its use in software is for primarily historical reasons.) Usually, the meta key is emulated by another key on your keyboard. On Windows and Linux, it is usually the Alt key. On Mac OS X, that key (aka Option) already has other uses, and so Escape is used instead.
Esc
For instance, if you wanted to go to the end of the file press
Esc then /
You don't need to hold down Esc as if it were Shift.
I do not know for nano, but for emacs, M- stands for the Meta key, which can mean pressing the Alt key simultaneously with the letter key or by pressing Esc key before the letter key. Alt generally only works when using an X version of the application, so when using a dumb terminal, only Esc will work.

Resources