sl@0: /* sl@0: * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: #include /* definition of exit() */ sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "CTEST.H" sl@0: sl@0: sl@0: sl@0: #define SIZE 10000 sl@0: sl@0: sl@0: sl@0: void Writer(void) sl@0: { sl@0: int Port; sl@0: SerialConfig sc; sl@0: char *buffer; sl@0: sl@0: Port = open("COM1:",0); sl@0: (void)ioctl(Port, COMMIOCTL_GETCONFIG, &sc); sl@0: sc.iRate = Bps115200; sl@0: sc.iParity = ParityNone; sl@0: (void)ioctl(Port, COMMIOCTL_SETCONFIG, &sc); sl@0: sl@0: buffer = (char*)malloc(SIZE); sl@0: memset(buffer, '*', SIZE); sl@0: sl@0: write(Port, buffer, SIZE); sl@0: sl@0: close(Port); sl@0: sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-STDLIB-CT-1101 sl@0: @SYMTestCaseDesc Tests for reading from the serial port sl@0: @SYMTestPriority High sl@0: @SYMTestActions Tests for reading into a buffer of size 1000 bytes from the serial port sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: void Reader(void) sl@0: { sl@0: int res; sl@0: int Port; sl@0: SerialConfig sc; sl@0: char *buffer, *p; sl@0: int x; sl@0: sl@0: sl@0: Port = open("COM2:",0); sl@0: res = ioctl(Port, COMMIOCTL_GETCONFIG, &sc); sl@0: sc.iRate = Bps115200; sl@0: sc.iParity = ParityNone; sl@0: res = ioctl(Port, COMMIOCTL_SETCONFIG, &sc); sl@0: sl@0: buffer = (char*)malloc(SIZE); sl@0: sl@0: res = 0; sl@0: p = buffer; sl@0: sl@0: sl@0: x = 5000; sl@0: res = ioctl(Port, COMMIOCTL_SETREADTIMEOUT, &x); sl@0: sl@0: for(x = 0;;x++) sl@0: { sl@0: res = read(Port, p, 100); sl@0: if (res > 0) sl@0: { sl@0: printf("read block %d int addr %x, bytes %d\n",x,p,res); sl@0: p += res; sl@0: } sl@0: sl@0: else sl@0: break; sl@0: } sl@0: sl@0: sl@0: x = 100; sl@0: res = ioctl(Port, COMMIOCTL_SETREADTHRESHOLD, &x); sl@0: p = buffer; sl@0: sl@0: printf("And again with a threshold of 100\n"); sl@0: sl@0: for(x = 0;;x++) sl@0: { sl@0: res = read(Port, p, 100); sl@0: if (res > 0) sl@0: { sl@0: printf("read block %d int addr %x, bytes %d\n",x,p,res); sl@0: p += res; sl@0: } sl@0: sl@0: else sl@0: break; sl@0: } sl@0: sl@0: sl@0: close(Port); sl@0: sl@0: } sl@0: sl@0: int main(void) sl@0: { sl@0: Reader(); sl@0: return 0; sl@0: } sl@0: