Update contrib.
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
17 #include <stdlib.h> /* definition of exit() */
21 #include <sys/unistd.h>
22 #include <sys/ioctl.h>
36 @SYMTestCaseID SYSLIB-STDLIB-CT-1102
37 @SYMTestCaseDesc Tests for serial port
39 @SYMTestActions Tests by writing a string buffer to the port
40 @SYMTestExpectedResults Test must not fail
47 buffer = (char*)malloc(SIZE);
48 memset(buffer, '*', SIZE);
50 printf("\nbig write\n");
51 (void)write(WriterPort, buffer, SIZE);
53 printf("\n>>Writer<<small read\n");
54 read(WriterPort,buffer,1);
55 printf("\nbig write\n");
56 write(WriterPort, buffer, SIZE);
57 printf("\n>>Writer<<small read\n");
58 read(WriterPort,buffer,1);
63 @SYMTestCaseID SYSLIB-STDLIB-CT-1103
64 @SYMTestCaseDesc Tests for serial port
66 @SYMTestActions Notifies on a read operation
67 @SYMTestExpectedResults Test must not fail
73 int notify[2] = {0,0};
77 res = ioctl(ReaderPort, COMMIOCTL_NOTIFYSUPPORTED, &supported);
78 printf("\nsupported notifies are %08x\n",supported);
81 notify[0] = supported;
82 printf("asking for %08x\n",notify[0]);
83 res = ioctl(ReaderPort, COMMIOCTL_NOTIFY, ¬ify[0]);
84 printf("\n**Notify** res = %d params %d, %d, errno %d\n",res, notify[0], notify[1],errno);
90 @SYMTestCaseID SYSLIB-STDLIB-CT-1104
91 @SYMTestCaseDesc Tests for serial port
93 @SYMTestActions Reads to buffer from serial port,test for failure conditions
94 @SYMTestExpectedResults Test must not fail
105 buffer = (char*)malloc(SIZE*2);
112 res = ioctl(ReaderPort, COMMIOCTL_SETREADTIMEOUT, &x);
116 res = read(ReaderPort, p, 100);
124 printf("\nread failed with errno %d\n",errno);
129 printf("\n>>Reader<<small write\n");
130 res = write(ReaderPort, buffer ,1);
132 printf("\n>>Reader<<set threshold\n");
134 res = ioctl(ReaderPort, COMMIOCTL_SETREADTHRESHOLD, &x);
137 printf("\nAnd again with a threshold of 100\n");
141 res = read(ReaderPort, p, 100);
149 printf("\nread failed with errno %d\n",errno);
154 printf("\n>>Reader<<Small write\n");
155 write(ReaderPort, buffer ,1);
164 int main(int, char**)
172 start_posix_server(); /* calls SpawnPosixServer from C++ code */
174 WriterPort = open("COM1:",0);
175 if (-1 == WriterPort)
177 (void)ioctl(WriterPort, COMMIOCTL_GETCONFIG, &sc);
179 sc.iRate = Bps115200;
180 sc.iParity = ParityNone;
181 (void)ioctl(WriterPort, COMMIOCTL_SETCONFIG, &sc);
183 ReaderPort = open("COM2:",0);
184 if (-1 == ReaderPort)
186 (void)ioctl(ReaderPort, COMMIOCTL_GETCONFIG, &sc);
188 sc.iRate = Bps115200;
189 sc.iParity = ParityNone;
190 (void)ioctl(ReaderPort, COMMIOCTL_SETCONFIG, &sc);
192 t3 = create_thread(Watcher, "watcher1");
193 t1 = create_thread(Reader, "reader");
194 t2 = create_thread(Writer, "writer");
200 (void)wait_for_thread(t1);
201 (void)wait_for_thread(t2);
205 (void)wait_for_thread(t3);
206 printf("\nPress a key\n");