

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
13 messages in net.java.dev.jna.usersRe: [jna-users] handling serial port ...| From | Sent On | Attachments |
|---|---|---|
| zamek | Mar 11, 2008 11:58 am | |
| Marc Ravensbergen | Mar 11, 2008 12:24 pm | |
| zamek | Mar 11, 2008 1:47 pm | |
| Timothy Wall | Mar 12, 2008 5:38 am | |
| zamek | Mar 12, 2008 2:34 pm | |
| Timothy Wall | Mar 12, 2008 4:36 pm | |
| zamek | Mar 13, 2008 1:12 pm | |
| Timothy Wall | Mar 13, 2008 5:04 pm | .java |
| zamek | Mar 14, 2008 7:26 am | |
| Timothy Wall | Mar 14, 2008 8:20 am | |
| zamek | Mar 14, 2008 8:51 am | |
| Timothy Wall | Mar 17, 2008 6:58 am | |
| zamek | Mar 17, 2008 11:22 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | Re: [jna-users] handling serial port with jna on linux | Actions... |
|---|---|---|
| From: | zamek (zam...@vili.pmmf.hu) | |
| Date: | Mar 13, 2008 1:12:03 pm | |
| List: | net.java.dev.jna.users | |
Hi All,
Ezzel a dátummal: Thursday 13 March 2008 00.37.00 Timothy Wall ezt írta:
For one thing, your sigset_t should be a total of 128 bytes (yours is 256); note that Java long is *not* the same thing as native long (NativeLong is). I don't think that would prevent the signal handler from being called, though.
Opps, thanks a lot, its true. Unfortunately this not helps for me:(
I see the manual and I don't understand how can I pass a signal address from java to native c?
original c code snippet is:
saio.sa_handler = signal_handler_IO; sigemptyset(&saio.sa_mask); //saio.sa_mask = 0; saio.sa_flags = 0; saio.sa_restorer = NULL; sigaction(SIGIO,&saio,NULL);
saio is a struct sigaction : __sighandler_t sa_handler; /* Additional set of signals to be blocked. */ __sigset_t sa_mask; /* Special flags. */ int sa_flags; /* Restore handler. */ void (*sa_restorer) (void);
__sighandler is a pointer to signal function in my java code
public interface SignalHandler_t extends Callback { public void callback(int signal); }
SigAction_t in java: public static class SigActionStruct extends Structure { public SignalHandler_t sa_handler; public SigSet_t sa_mask; public int sa_flags; public SignalRestorer sa_restorer; }
and I create Sigaction:
SignalHandler_t signal = new SignalHandler_t (){ @Override public void callback(int signal) { int st = 0; CLibrary.INSTANCE.ioctl(dev, CLibrary.TIOCMGET, st); st &= ~CLibrary.TIOCM_RTS; CLibrary.INSTANCE.ioctl(dev, CLibrary.TIOCMSET, st); st |= CLibrary.TIOCM_RTS; CLibrary.INSTANCE.ioctl(dev, CLibrary.TIOCMSET, st); }};
and I fill SigActionStruct: SigActionStruct saio = new SigActionStruct(); saio.sa_handler = this.signal; CLibrary.INSTANCE.sigemptyset(saio.sa_mask); saio.sa_flags = 0; saio.sa_restorer = null; int saRes = CLibrary.INSTANCE.sigaction(CLibrary.SIGIO, saio, null);
original sigaction in c:
extern int sigaction (int __sig, __const struct sigaction *__restrict __act, struct sigaction *__restrict __oact) __THROW;
which mean restrict_act and restrict_oact is pointers!
java sigaction of library declaration is: int sigaction (int sig, SigActionStruct act, SigActionStruct oact);
I tried : int sigaction (int sig, Pointer act, Pointer oact); and int saRes = CLibrary.INSTANCE.sigaction(CLibrary.SIGIO, saio.getPointer(), null);
but it doesn't help:(
Could somebody ever used signal callback ? Is there an example somewhere? google and codesearch.google cannot help:(
-- thx, ---------------------------------- Zoltan Zidarics programmer PTE-PMMFK H-7621 Pecs, Boszorkany u. 2. Hungary E-Mail: zam...@vili.pmmf.hu ----------------------------------








.java