2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
9 /*********************************************************************************************/
14 #include <aros/debug.h>
16 #include <prefs/prefhdr.h>
17 #include <prefs/serial.h>
19 static const ULONG buffersizes
[] =
30 static LONG stopchunks
[] =
35 /*********************************************************************************************/
37 void SerialPrefs_Handler(STRPTR filename
)
39 struct IFFHandle
*iff
;
40 struct SerialPrefs
*serialprefs
;
42 D(bug("In IPrefs:SerialPrefs_Handler\n"));
43 D(bug("filename=%s\n",filename
));
45 iff
= CreateIFF(filename
, stopchunks
, 1);
48 while(ParseIFF(iff
, IFFPARSE_SCAN
) == 0) {
49 serialprefs
= LoadChunk(iff
, sizeof(struct SerialPrefs
), MEMF_ANY
);
51 struct Preferences prefs
;
54 GetPrefs(&prefs
, sizeof(prefs
));
56 while (-1 != buffersizes
[index
]) {
57 if (buffersizes
[index
] == serialprefs
->sp_InputBuffer
)
62 if (-1 == buffersizes
[index
])
65 D(bug("Setting new serial prefs.\n"));
66 D(bug("Setting baudrate to %d\n", GET_LONG(serialprefs
->sp_BaudRate
)));
67 D(bug("Setting receive buffer size to %d\n",buffersizes
[index
]));
68 D(bug("Setting read bit len to %d\n",8-serialprefs
->sp_BitsPerChar
));
69 D(bug("Setting write bit len to %d\n",8-serialprefs
->sp_BitsPerChar
));
70 D(bug("Setting stop bits to %d\n",1+serialprefs
->sp_StopBits
));
72 prefs
.BaudRate
= GET_LONG(serialprefs
->sp_BaudRate
);
73 prefs
.SerRWBits
= (serialprefs
->sp_BitsPerChar
<< 4) | serialprefs
->sp_BitsPerChar
;
74 prefs
.SerStopBuf
= (serialprefs
->sp_StopBits
<< 4) | index
;
75 prefs
.SerParShk
= (serialprefs
->sp_Parity
<< 4) | serialprefs
->sp_InputHandshake
;
77 SetPrefs(&prefs
, sizeof(prefs
), TRUE
);