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: @SYMTestCaseID SYSLIB-STDLIB-CT-1100 sl@0: @SYMTestCaseDesc Tests for writing to the serial port sl@0: @SYMTestPriority High sl@0: @SYMTestActions Tests for writing a buffer of size 1000 bytes to the serial port sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 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: printf("writing monster block\n"); sl@0: write(Port, buffer, SIZE); sl@0: sl@0: sl@0: printf("press a key\n"); sl@0: getchar(); sl@0: sl@0: printf("writing monster block again\n"); sl@0: write(Port, buffer, SIZE); sl@0: sl@0: close(Port); sl@0: sl@0: } 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: sl@0: Port = open("COM1:",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: for(;;) sl@0: { sl@0: res = read(Port, p, 100); sl@0: if (res > 0) sl@0: p += res; sl@0: else sl@0: break; sl@0: } 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: Writer(); sl@0: return 0; sl@0: } sl@0: