Difference between revisions of "Serial Open"

From WikiPrizm
Jump to navigationJump to search
m
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{DISPLAYTITLE:Serial_Open}}
+
{{syscall
== Synopsis ==
+
| name = Serial_Open
'''Syscall index: 0x1BB7'''
+
| header = fxcg/serial.h
 
+
| index = 0x1BB7
'''Function signature:''' int Serial_Open(unsigned char *mode)
+
| signature = int Serial_Open(unsigned char* mode)
 
+
| synopsis = Opens the 3-pin serial port with the specified parameters.
== Inputs ==
+
| parameters = * '''mode''' - pointer to a six-byte array containing the settings for the serial port:
'''mode''': a 6-byte array specifying the desired communication parameters.  Summarized in the table below.
+
{{{!}}
{|
 
 
! Index
 
! Index
 
! Description
 
! Description
 
! Values
 
! Values
|-
+
{{!}}-
| 0 || Unknown || Always 0
+
{{!}} 0 {{!}}{{!}} Unknown {{!}}{{!}} Always 0
|-
+
{{!}}-
| 1 || Bit rate ||
+
{{!}} 1 {{!}}{{!}} Bit rate {{!}}{{!}}
{|
+
{{{!}}
 
! Value
 
! Value
 
! Rate
 
! Rate
|-
+
{{!}}-
| 0 || 300
+
{{!}} 0 {{!}}{{!}} 300
|-
+
{{!}}-
| 1 || 600
+
{{!}} 1 {{!}}{{!}} 600
|-
+
{{!}}-
| 2 || 1200
+
{{!}} 2 {{!}}{{!}} 1200
|-
+
{{!}}-
| 3 || 2400
+
{{!}} 3 {{!}}{{!}} 2400
|-
+
{{!}}-
| 4 || 4800
+
{{!}} 4 {{!}}{{!}} 4800
|-
+
{{!}}-
| 5 || 9600
+
{{!}} 5 {{!}}{{!}} 9600
|-
+
{{!}}-
| 6 || 19200
+
{{!}} 6 {{!}}{{!}} 19200
|-
+
{{!}}-
| 7 || 38400
+
{{!}} 7 {{!}}{{!}} 38400
|-
+
{{!}}-
| 8 || 57600
+
{{!}} 8 {{!}}{{!}} 57600
|-
+
{{!}}-
| 9 || 115200
+
{{!}} 9 {{!}}{{!}} 115200
|}
+
{{!}}}
|-
+
{{!}}-
| 2 || Parity ||
+
{{!}} 2 {{!}}{{!}} Parity {{!}}{{!}}
{|
+
{{{!}}
 
! Value
 
! Value
 
! Parity
 
! Parity
|-
+
{{!}}-
| 0 || None
+
{{!}} 0 {{!}}{{!}} None
|-
+
{{!}}-
| 1 || Odd
+
{{!}} 1 {{!}}{{!}} Odd
|-
+
{{!}}-
| 2 || Even
+
{{!}} 2 {{!}}{{!}} Even
|}
+
{{!}}}
|-
+
{{!}}-
| 3 || Data length ||
+
{{!}} 3 {{!}}{{!}} Data length {{!}}{{!}}
{|
+
{{{!}}
 
! Value
 
! Value
 
! Length (bits)
 
! Length (bits)
|-
+
{{!}}-
| 0 || 8
+
{{!}} 0 {{!}}{{!}} 8
|-  
+
{{!}}-  
| 1 || 7
+
{{!}} 1 {{!}}{{!}} 7
|}
+
{{!}}}
|-
+
{{!}}-
| 4 || Stop bits ||
+
{{!}} 4 {{!}}{{!}} Stop bits {{!}}{{!}}
{|
+
{{{!}}
 
! Value
 
! Value
 
! Stop bits
 
! Stop bits
|-
+
{{!}}-
| 0 || 1
+
{{!}} 0 {{!}}{{!}} 1
|-
+
{{!}}-
| 1 || 2
+
{{!}} 1 {{!}}{{!}} 2
|}
+
{{!}}}
|-
+
{{!}}-
| 5 || Unused || Always 0
+
{{!}} 5 {{!}}{{!}} Unused {{!}}{{!}} Always 0
|}
+
{{!}}}
 
+
| returns = * 0 if successful;
 
+
* 3 if the serial port is already open;
== Outputs ==
+
* 4 if '''mode'''[0] is not zero.
Returns 0 for success, 3 if the serial port is already open, and 4 if the byte at index 0 was not 0.
+
| example = Check if the serial port is already open, and configure it for 9600 bps 8N1 operation if not.
 
 
== Example ==
 
Check if the serial port is already open, and configure it for 9600 bps 8n1 operation if not.
 
 
  if (Serial_IsOpen() != 1) {
 
  if (Serial_IsOpen() != 1) {
 
     unsigned char mode[6] = {0, 5, 0, 0, 0, 0};    // 9600 bps 8n1
 
     unsigned char mode[6] = {0, 5, 0, 0, 0, 0};    // 9600 bps 8n1
 
     Serial_Open(mode);
 
     Serial_Open(mode);
 
  }
 
  }
 
+
}}
[[Category:Syscalls|Serial_Open]]
+
[[Category:Syscalls:Serial]]

Latest revision as of 06:20, 1 August 2014


Synopsis

Header: fxcg/serial.h
Syscall index: 0x1BB7
Function signature: int Serial_Open(unsigned char* mode)

Opens the 3-pin serial port with the specified parameters.

Parameters

  • mode - pointer to a six-byte array containing the settings for the serial port:
Index Description Values
0 Unknown Always 0
1 Bit rate
Value Rate
0 300
1 600
2 1200
3 2400
4 4800
5 9600
6 19200
7 38400
8 57600
9 115200
2 Parity
Value Parity
0 None
1 Odd
2 Even
3 Data length
Value Length (bits)
0 8
1 7
4 Stop bits
Value Stop bits
0 1
1 2
5 Unused Always 0


Returns

  • 0 if successful;
  • 3 if the serial port is already open;
  • 4 if mode[0] is not zero.

Example

Check if the serial port is already open, and configure it for 9600 bps 8N1 operation if not.

if (Serial_IsOpen() != 1) {
    unsigned char mode[6] = {0, 5, 0, 0, 0, 0};    // 9600 bps 8n1
    Serial_Open(mode);
}