Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
etherlabmaster
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ICS Control System Infrastructure
etherlabmaster
Commits
a9fbf2c2
Commit
a9fbf2c2
authored
15 years ago
by
Florian Pose
Browse files
Options
Downloads
Patches
Plain Diff
Create tty.
parent
a2464ebe
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/tty/tty.c
+25
-4
25 additions, 4 deletions
examples/tty/tty.c
with
25 additions
and
4 deletions
examples/tty/tty.c
+
25
−
4
View file @
a9fbf2c2
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
#endif
#endif
#include
"../../include/ecrt.h"
// EtherCAT realtime interface
#include
"../../include/ecrt.h"
// EtherCAT realtime interface
#include
"../../include/ectty.h"
// EtherCAT TTY interface
/*****************************************************************************/
/*****************************************************************************/
...
@@ -117,6 +118,7 @@ typedef struct {
...
@@ -117,6 +118,7 @@ typedef struct {
static
serial_device_t
*
ser
=
NULL
;
static
serial_device_t
*
ser
=
NULL
;
static
char
tx_data
[]
=
"ATZ
\r\n
"
;
static
char
tx_data
[]
=
"ATZ
\r\n
"
;
static
off_t
tx_off
=
0
;
static
off_t
tx_off
=
0
;
static
ec_tty_t
*
tty
=
NULL
;
/*****************************************************************************/
/*****************************************************************************/
...
@@ -444,21 +446,30 @@ int __init init_mini_module(void)
...
@@ -444,21 +446,30 @@ int __init init_mini_module(void)
printk
(
KERN_INFO
PFX
"Starting...
\n
"
);
printk
(
KERN_INFO
PFX
"Starting...
\n
"
);
ser
=
kmalloc
(
sizeof
(
*
ser
),
GFP_KERNEL
);
ser
=
kmalloc
(
sizeof
(
*
ser
),
GFP_KERNEL
);
if
(
ser
==
NULL
)
{
if
(
!
ser
)
{
printk
(
KERN_ERR
PFX
"Failed to allocate serial device object.
\n
"
);
printk
(
KERN_ERR
PFX
"Failed to allocate serial device object.
\n
"
);
return
-
ENOMEM
;
ret
=
-
ENOMEM
;
goto
out_return
;
}
}
ret
=
serial_init
(
ser
,
22
,
22
);
ret
=
serial_init
(
ser
,
22
,
22
);
if
(
ret
)
{
if
(
ret
)
{
printk
(
KERN_ERR
PFX
"Failed to init serial device object.
\n
"
);
printk
(
KERN_ERR
PFX
"Failed to init serial device object.
\n
"
);
return
ret
;
goto
out_free_serial
;
}
tty
=
ectty_create
();
if
(
IS_ERR
(
tty
))
{
printk
(
KERN_ERR
PFX
"Failed to create tty.
\n
"
);
ret
=
PTR_ERR
(
tty
);
goto
out_serial
;
}
}
master
=
ecrt_request_master
(
0
);
master
=
ecrt_request_master
(
0
);
if
(
!
master
)
{
if
(
!
master
)
{
ret
=
-
EBUSY
;
ret
=
-
EBUSY
;
printk
(
KERN_ERR
PFX
"Requesting master 0 failed.
\n
"
);
printk
(
KERN_ERR
PFX
"Requesting master 0 failed.
\n
"
);
goto
out_
return
;
goto
out_
tty
;
}
}
init_MUTEX
(
&
master_sem
);
init_MUTEX
(
&
master_sem
);
...
@@ -513,6 +524,12 @@ int __init init_mini_module(void)
...
@@ -513,6 +524,12 @@ int __init init_mini_module(void)
out_release_master:
out_release_master:
printk
(
KERN_ERR
PFX
"Releasing master...
\n
"
);
printk
(
KERN_ERR
PFX
"Releasing master...
\n
"
);
ecrt_release_master
(
master
);
ecrt_release_master
(
master
);
out_tty:
ectty_free
(
tty
);
out_serial:
serial_clear
(
ser
);
out_free_serial:
kfree
(
ser
);
out_return:
out_return:
printk
(
KERN_ERR
PFX
"Failed to load. Aborting.
\n
"
);
printk
(
KERN_ERR
PFX
"Failed to load. Aborting.
\n
"
);
return
ret
;
return
ret
;
...
@@ -529,6 +546,10 @@ void __exit cleanup_mini_module(void)
...
@@ -529,6 +546,10 @@ void __exit cleanup_mini_module(void)
printk
(
KERN_INFO
PFX
"Releasing master...
\n
"
);
printk
(
KERN_INFO
PFX
"Releasing master...
\n
"
);
ecrt_release_master
(
master
);
ecrt_release_master
(
master
);
ectty_free
(
tty
);
serial_clear
(
ser
);
kfree
(
ser
);
printk
(
KERN_INFO
PFX
"Unloading.
\n
"
);
printk
(
KERN_INFO
PFX
"Unloading.
\n
"
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment