1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/TSTLIB/tser2w.c Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,107 @@
1.4 +/*
1.5 +* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +#include <stdlib.h> /* definition of exit() */
1.24 +#include <stdio.h>
1.25 +#include <errno.h>
1.26 +#include <string.h>
1.27 +#include <sys/unistd.h>
1.28 +#include <sys/ioctl.h>
1.29 +#include "CTEST.H"
1.30 +
1.31 +
1.32 +
1.33 +#define SIZE 10000
1.34 +
1.35 +/**
1.36 +@SYMTestCaseID SYSLIB-STDLIB-CT-1100
1.37 +@SYMTestCaseDesc Tests for writing to the serial port
1.38 +@SYMTestPriority High
1.39 +@SYMTestActions Tests for writing a buffer of size 1000 bytes to the serial port
1.40 +@SYMTestExpectedResults Test must not fail
1.41 +@SYMREQ REQ0000
1.42 +*/
1.43 +void Writer(void)
1.44 + {
1.45 + int Port;
1.46 + SerialConfig sc;
1.47 + char *buffer;
1.48 +
1.49 + Port = open("COM1:",0);
1.50 + (void)ioctl(Port, COMMIOCTL_GETCONFIG, &sc);
1.51 + sc.iRate = Bps115200;
1.52 + sc.iParity = ParityNone;
1.53 + (void)ioctl(Port, COMMIOCTL_SETCONFIG, &sc);
1.54 +
1.55 + buffer = (char*)malloc(SIZE);
1.56 + memset(buffer, '*', SIZE);
1.57 +
1.58 + printf("writing monster block\n");
1.59 + write(Port, buffer, SIZE);
1.60 +
1.61 +
1.62 + printf("press a key\n");
1.63 + getchar();
1.64 +
1.65 + printf("writing monster block again\n");
1.66 + write(Port, buffer, SIZE);
1.67 +
1.68 + close(Port);
1.69 +
1.70 + }
1.71 +
1.72 +void Reader(void)
1.73 + {
1.74 + int res;
1.75 + int Port;
1.76 + SerialConfig sc;
1.77 + char *buffer, *p;
1.78 +
1.79 + Port = open("COM1:",0);
1.80 + res = ioctl(Port, COMMIOCTL_GETCONFIG, &sc);
1.81 + sc.iRate = Bps115200;
1.82 + sc.iParity = ParityNone;
1.83 + res = ioctl(Port, COMMIOCTL_SETCONFIG, &sc);
1.84 +
1.85 + buffer = (char*)malloc(SIZE);
1.86 +
1.87 + res = 0;
1.88 + p = buffer;
1.89 +
1.90 + for(;;)
1.91 + {
1.92 + res = read(Port, p, 100);
1.93 + if (res > 0)
1.94 + p += res;
1.95 + else
1.96 + break;
1.97 + }
1.98 +
1.99 +
1.100 +
1.101 + close(Port);
1.102 +
1.103 + }
1.104 +
1.105 +int main(void)
1.106 + {
1.107 + Writer();
1.108 + return 0;
1.109 + }
1.110 +