0

tl;dr

What does VxWorks use for a newline in a terminal (console) application?

Background

I am trying to work out what newline sequence is expected by vxWorks (e.g. std::endl or similar mechanisms). Of course, Windows uses "\r\n", Linux uses "\n", with a laundry list of OS implementations listed on Wikipedia ... except VxWorks! Nor is the documentation very clear on the subject.

Damien
  • 785
  • 3
  • 8
  • 18

1 Answers1

1

Newline character is "\n", as it is in most OSes, You can run the following code to check yourself.

#include "vxWorks.h"
#include "stdio.h"

void start(void) {

 printf("First Line:\n");
 printf("Second Line:\n");
 printf("Fourth Line:");
 printf("Fifth Line:\n");
 printf("Sixth  Line:\n");

}

If you load and run the above module(if running in kernel mode), you will get out put as:-

-> ld < so.out
->value = 944654968 = 0x384e4a78 = 'x'
-> start
First Line:
Second Line:
Fourth Line:Fifth Line:
Sixth  Line:
value = 10 = 0xa
->

Edit: text segment of the dkm

[vxWorks *]# module 

MODULE NAME     MODULE ID  GROUP #    TEXT START DATA START  BSS START
--------------- ---------- ---------- ---------- ---------- ----------
so.out          0x384f7aa8          2 0x10640000 NO SEGMENT 0x10650000
[vxWorks *]# d 0x10640000
NOTE: memory values are displayed in hexadecimal.
0x10640000:  8955 83e5 18ec 04c7 4424 6400 e810 48ee  *U.......$D.d...H*
0x10640010:  ffb4 04c7 5024 6400 e810 48e2 ffb4 04c7  *....$P.d...H....*
0x10640020:  5d24 6400 e810 d196 ffb7 04c7 6a24 6400  *$].d........$j.d*
0x10640030:  e810 48ca ffb4 04c7 7624 6400 e810 48be  *...H....$v.d...H*
0x10640040:  ffb4 c3c9 6946 7372 2074 694c 656e 003a  *....First Line:.*
0x10640050:  6553 6f63 646e 4c20 6e69 3a65 4600 756f  *Second Line:.Fou*
0x10640060:  7472 2068 694c 656e 003a 6946 7466 2068  *rth Line:.Fifth *
0x10640070:  694c 656e 003a 6953 7478 2068 4c20 6e69  *Line:.Sixth  Lin*
0x10640080:  3a65 0000 0014 0000 0000 0000 7a01 0052  *e:...........zR.*
0x10640090:  7c01 0108 0c1b 0404 0188 0000 001c 0000  *.|..............*
0x106400a0:  001c 0000 ff5c ffff 0044 0000 4100 080e  *....\...D....A..*
0x106400b0:  0285 0d42 0205 c540 040c 0004 0000 0000  *..B...@.........*
0x106400c0:  6174 2067 4d53 2050 0030 6e65 0064 0000  *tag SMP 0.end...*
0x106400d0:  0000 0000 0000 0000 0000 0000 0000 0000  *................*
0x106400e0:  0000 0000 0000 0000 0000 0000 0000 0000  *................*
0x106400f0:  0000 0000 0000 0000 0000 0000 0000 0000  *................*
[vxWorks *]# 
finickyTunnel
  • 148
  • 2
  • 14
  • Thanks for the answer. I don't have a VxWorks platform to test with, but could you please confirm with a "hexdump" utility. For example, under Linux it would be ./start | hexdump -c and we will be able to see which characters make it to the console. Some OS (e.g. Windows) will silently translate the "\n" to "\r\n" when writing to the console. – Damien Mar 08 '17 at 09:02
  • I am not sure about hexdump or relevant utility in VxWorks, but if it helps, I am appending to the answer, the text segment of the kernel module – finickyTunnel Mar 10 '17 at 04:20
  • Unfortunately, the text of the module isn't helpful. The character stream of the output of the program is. – Damien Mar 10 '17 at 04:38
  • I think \n\r is only relevant to windows. Since VxWorks is POSIX compliant , I assume it wouldnt be any different than linux. You may also want to check this discussion , If you have not checked it already http://stackoverflow.com/questions/1761051/difference-between-n-and-r[link] – finickyTunnel Mar 10 '17 at 10:35