Log in
Register
Menu
Log in
Register
Home
What's new
Latest activity
Authors
Forums
New posts
Search forums
What's new
New posts
Latest activity
Members
Current visitors
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Satellite TV receivers & systems support forums
Satellite PC Card Receivers, Internet by Satellite
StreamReader.dll in C#?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="drhans" data-source="post: 993235" data-attributes="member: 333600"><p>Hello</p><p></p><p>I'm trying to write an application using streamreader.dll to simply stream filtered transponder data over HTTP once a client requests that specific data. The client could be a Dreambox or OSEmu for example. Basically anything that will further process the data. After some not so great results in C++ I decided to use C# instead because I'm hoping the handling of client connections and threads plus the GUI will be somewhat easier.</p><p></p><p>streamreader.dll should work, right? And in part it does - i can tune in to a frequency and set filter, but the problem I'm having is with the callback function which is supposed to read the data. The problem is that I'm only getting one byte in the buffer, it's byte 0x47, which means it works in part, but where are the other 187 bytes? The len parameter clearly shows the streamingCB function got 188 bytes, yet the buffer contains just one. I'm stuck here and I have no idea if this is my c# coding error or incorrect use of the streamreader.dll.</p><p></p><p>Here's my code. And a screenshot of what I get is attached. Any help would be much appreciated. I think such application would be quite helpful, so far I don't think anything like this exists!</p><p></p><p>[CODE]</p><p>using System;</p><p>using System.Collections.Generic;</p><p>using System.Linq;</p><p>using System.Text;</p><p>using System.Threading.Tasks;</p><p>using System.Windows;</p><p>using System.Windows.Controls;</p><p>using System.Windows.Data;</p><p>using System.Windows.Documents;</p><p>using System.Windows.Input;</p><p>using System.Windows.Media;</p><p>using System.Windows.Media.Imaging;</p><p>using System.Windows.Navigation;</p><p>using System.Windows.Shapes;</p><p>using System.Runtime.InteropServices;</p><p>namespace SimpleSatServer</p><p>{</p><p> /// <summary></p><p> /// Interaction logic for MainWindow.xaml</p><p> /// </summary></p><p> /// </p><p> public class DVB_card</p><p> {</p><p> public DVB_card(string name, int id)</p><p> {</p><p> this.Name = name; this.Id = id;</p><p> }</p><p> public string Name</p><p> { get; set; }</p><p> public int Id</p><p> { get; set; }</p><p> }</p><p> public partial class MainWindow : Window</p><p> {</p><p> public static MainWindow GUI { get; private set; }</p><p> //[DllImport("dlltest.dll", CallingConvention = CallingConvention.Cdecl)]</p><p> //public static extern void StreamingCB2(byte[] buffer, Int32 len);</p><p> [DllImport("StreamReader.dll", CallingConvention = CallingConvention.Cdecl)]</p><p> public static extern bool StartDVBEx(Int32 index);</p><p> [DllImport("StreamReader.dll", CallingConvention = CallingConvention.Cdecl)]</p><p> public static extern bool StopDVB();</p><p> [DllImport("StreamReader.dll", CallingConvention = CallingConvention.Cdecl)]</p><p> public static extern bool CheckForDVB();</p><p> [DllImport("StreamReader.dll", CallingConvention = CallingConvention.Cdecl)]</p><p> public static extern UInt32 GetCaps();</p><p> public delegate void DVBCallbackFunc(int index, String name);</p><p> [DllImport("StreamReader.dll", CallingConvention = CallingConvention.Cdecl)]</p><p> public static extern bool CheckForDVBEx(DVBCallbackFunc func);</p><p> [DllImport("StreamReader.dll", CallingConvention = CallingConvention.Cdecl)]</p><p> public static extern bool GetSignal(ulong Level, ulong Quality);</p><p> [DllImport("StreamReader.dll", CallingConvention = CallingConvention.Cdecl)]</p><p> public static extern bool SetChannelEx(Int32 freq, Int32 symbrate, Int32 pol, Int32 fec, Int32 lof1, Int32 lof2, Int32 lofsw, Int32 mod);</p><p> [DllImport("StreamReader.dll", CallingConvention = CallingConvention.Cdecl)]</p><p> public unsafe static extern bool GetSignalExEx(bool* pPresent, bool* pLock, int* pRFLevel, float* pSNR, float* pBER);</p><p> public unsafe delegate void StreamingCallbackFunc(byte[] buffer, int len);</p><p> [DllImport("StreamReader.dll", CallingConvention = CallingConvention.Cdecl)]</p><p> public unsafe static extern bool SetFilter(int pid, StreamingCallbackFunc lpFunc, Int32 CallBackType, Int32 size, Int32* lpfilter_num);</p><p> </p><p> </p><p> public MainWindow()</p><p> {</p><p> InitializeComponent();</p><p> log("Looking for DVB tuners... ");</p><p> CheckForDVBEx(InfoCB);</p><p> dvb_dev_list.SelectedIndex = 0;</p><p> }</p><p> </p><p> public void InfoCB(int index, String name)</p><p> {</p><p> dvb_dev_list.Items.Add(new DVB_card(name, index));</p><p> log("Found DVB tuner " + name);</p><p> }</p><p> </p><p> public void StreamingCB(byte[] buffer, int len)</p><p> {</p><p> log("BUFFER LEN: " + buffer.Length);</p><p> log("LEN: " + len.ToString());</p><p> log("BUFFER: " + BitConverter.ToString(buffer));</p><p> //System.IO.File.WriteAllBytes("file.ts", buffer);</p><p> }</p><p> </p><p> public void log(string tolog)</p><p> {</p><p> try { </p><p> this.Dispatcher.Invoke(() =></p><p> {</p><p> log_window.AppendText(DateTime.Now.ToString("H:mm:ss") + ": " + tolog + "\n");</p><p> log_window.ScrollToEnd();</p><p> });</p><p> }</p><p> catch</p><p> {</p><p> }</p><p> </p><p> }</p><p></p><p> private void Button_Click(object sender, RoutedEventArgs e)</p><p> {</p><p> //public static extern void DisplayHelloFromDLL();</p><p> Int32 nr = dvb_dev_list.SelectedIndex;</p><p> if (!StartDVBEx(nr))</p><p> {</p><p> log(string.Format("StartDVBEx({0}) fail", nr));</p><p> dvb_dev_list.Background = Brushes.Red;</p><p> }</p><p> else</p><p> {</p><p> log(string.Format("StartDVBEx({0}) OK", nr));</p><p> dvb_dev_list.Background = Brushes.Green;</p><p> dvb_deb_stop.IsEnabled = true;</p><p> dvb_deb_start.IsEnabled = false;</p><p> dvb_dev_list.IsEnabled = false; </p><p> } </p><p> }</p><p> private void Button_Click_1(object sender, RoutedEventArgs e)</p><p> {</p><p> </p><p> if (!StopDVB())</p><p> {</p><p> log(string.Format("StopDVB err"));</p><p> }</p><p> else</p><p> {</p><p> log(string.Format("StopDVB OK"));</p><p> dvb_dev_list.ClearValue(Button.BackgroundProperty);</p><p> dvb_dev_list.IsEnabled = true;</p><p> dvb_deb_start.IsEnabled = true;</p><p> dvb_deb_stop.IsEnabled = false;</p><p> sig_info_lock.ClearValue(Button.BackgroundProperty);</p><p> sig_info_snr.Content = "";</p><p> }</p><p> }</p><p> private unsafe void btn_signal_info_Click(object sender, RoutedEventArgs e)</p><p> {</p><p> sig_info_lock.ClearValue(Button.BackgroundProperty);</p><p> sig_info_snr.Content = "";</p><p> if (!SetChannelEx(11804000, 27500000, 1, 0, 97500000, 10600000, 11700000, 0))</p><p> {</p><p> log(string.Format("SetChannelEx err"));</p><p> }</p><p> bool pPresent;</p><p> bool pLock;</p><p> int pRFLevel;</p><p> float pSNR;</p><p> float pBER;</p><p> GetSignalExEx(&pPresent, &pLock, &pRFLevel, &pSNR, &pBER);</p><p> log("Signal Present: " + pPresent.ToString());</p><p> log("Signal Lock: " + pLock.ToString());</p><p> log("Signal SNR: " + pSNR.ToString());</p><p> log("Signal BER: " + pBER.ToString());</p><p> log("Signal RF: " + pRFLevel.ToString());</p><p> if (pLock)</p><p> {</p><p> sig_info_lock.Background = Brushes.Green;</p><p> sig_info_snr.Content = pSNR.ToString() + " dB";</p><p> }</p><p> int filter1;</p><p> StreamingCallbackFunc sh = StreamingCB;</p><p> if (!SetFilter(17, sh, 4, 1, &filter1))</p><p> {</p><p> log("Filter fail");</p><p> }</p><p> else</p><p> {</p><p> log("Filter set");</p><p> }</p><p> }</p><p> }</p><p>}</p><p></p><p>[/CODE]</p></blockquote><p></p>
[QUOTE="drhans, post: 993235, member: 333600"] Hello I'm trying to write an application using streamreader.dll to simply stream filtered transponder data over HTTP once a client requests that specific data. The client could be a Dreambox or OSEmu for example. Basically anything that will further process the data. After some not so great results in C++ I decided to use C# instead because I'm hoping the handling of client connections and threads plus the GUI will be somewhat easier. streamreader.dll should work, right? And in part it does - i can tune in to a frequency and set filter, but the problem I'm having is with the callback function which is supposed to read the data. The problem is that I'm only getting one byte in the buffer, it's byte 0x47, which means it works in part, but where are the other 187 bytes? The len parameter clearly shows the streamingCB function got 188 bytes, yet the buffer contains just one. I'm stuck here and I have no idea if this is my c# coding error or incorrect use of the streamreader.dll. Here's my code. And a screenshot of what I get is attached. Any help would be much appreciated. I think such application would be quite helpful, so far I don't think anything like this exists! [CODE] using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Runtime.InteropServices; namespace SimpleSatServer { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> /// public class DVB_card { public DVB_card(string name, int id) { this.Name = name; this.Id = id; } public string Name { get; set; } public int Id { get; set; } } public partial class MainWindow : Window { public static MainWindow GUI { get; private set; } //[DllImport("dlltest.dll", CallingConvention = CallingConvention.Cdecl)] //public static extern void StreamingCB2(byte[] buffer, Int32 len); [DllImport("StreamReader.dll", CallingConvention = CallingConvention.Cdecl)] public static extern bool StartDVBEx(Int32 index); [DllImport("StreamReader.dll", CallingConvention = CallingConvention.Cdecl)] public static extern bool StopDVB(); [DllImport("StreamReader.dll", CallingConvention = CallingConvention.Cdecl)] public static extern bool CheckForDVB(); [DllImport("StreamReader.dll", CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 GetCaps(); public delegate void DVBCallbackFunc(int index, String name); [DllImport("StreamReader.dll", CallingConvention = CallingConvention.Cdecl)] public static extern bool CheckForDVBEx(DVBCallbackFunc func); [DllImport("StreamReader.dll", CallingConvention = CallingConvention.Cdecl)] public static extern bool GetSignal(ulong Level, ulong Quality); [DllImport("StreamReader.dll", CallingConvention = CallingConvention.Cdecl)] public static extern bool SetChannelEx(Int32 freq, Int32 symbrate, Int32 pol, Int32 fec, Int32 lof1, Int32 lof2, Int32 lofsw, Int32 mod); [DllImport("StreamReader.dll", CallingConvention = CallingConvention.Cdecl)] public unsafe static extern bool GetSignalExEx(bool* pPresent, bool* pLock, int* pRFLevel, float* pSNR, float* pBER); public unsafe delegate void StreamingCallbackFunc(byte[] buffer, int len); [DllImport("StreamReader.dll", CallingConvention = CallingConvention.Cdecl)] public unsafe static extern bool SetFilter(int pid, StreamingCallbackFunc lpFunc, Int32 CallBackType, Int32 size, Int32* lpfilter_num); public MainWindow() { InitializeComponent(); log("Looking for DVB tuners... "); CheckForDVBEx(InfoCB); dvb_dev_list.SelectedIndex = 0; } public void InfoCB(int index, String name) { dvb_dev_list.Items.Add(new DVB_card(name, index)); log("Found DVB tuner " + name); } public void StreamingCB(byte[] buffer, int len) { log("BUFFER LEN: " + buffer.Length); log("LEN: " + len.ToString()); log("BUFFER: " + BitConverter.ToString(buffer)); //System.IO.File.WriteAllBytes("file.ts", buffer); } public void log(string tolog) { try { this.Dispatcher.Invoke(() => { log_window.AppendText(DateTime.Now.ToString("H:mm:ss") + ": " + tolog + "\n"); log_window.ScrollToEnd(); }); } catch { } } private void Button_Click(object sender, RoutedEventArgs e) { //public static extern void DisplayHelloFromDLL(); Int32 nr = dvb_dev_list.SelectedIndex; if (!StartDVBEx(nr)) { log(string.Format("StartDVBEx({0}) fail", nr)); dvb_dev_list.Background = Brushes.Red; } else { log(string.Format("StartDVBEx({0}) OK", nr)); dvb_dev_list.Background = Brushes.Green; dvb_deb_stop.IsEnabled = true; dvb_deb_start.IsEnabled = false; dvb_dev_list.IsEnabled = false; } } private void Button_Click_1(object sender, RoutedEventArgs e) { if (!StopDVB()) { log(string.Format("StopDVB err")); } else { log(string.Format("StopDVB OK")); dvb_dev_list.ClearValue(Button.BackgroundProperty); dvb_dev_list.IsEnabled = true; dvb_deb_start.IsEnabled = true; dvb_deb_stop.IsEnabled = false; sig_info_lock.ClearValue(Button.BackgroundProperty); sig_info_snr.Content = ""; } } private unsafe void btn_signal_info_Click(object sender, RoutedEventArgs e) { sig_info_lock.ClearValue(Button.BackgroundProperty); sig_info_snr.Content = ""; if (!SetChannelEx(11804000, 27500000, 1, 0, 97500000, 10600000, 11700000, 0)) { log(string.Format("SetChannelEx err")); } bool pPresent; bool pLock; int pRFLevel; float pSNR; float pBER; GetSignalExEx(&pPresent, &pLock, &pRFLevel, &pSNR, &pBER); log("Signal Present: " + pPresent.ToString()); log("Signal Lock: " + pLock.ToString()); log("Signal SNR: " + pSNR.ToString()); log("Signal BER: " + pBER.ToString()); log("Signal RF: " + pRFLevel.ToString()); if (pLock) { sig_info_lock.Background = Brushes.Green; sig_info_snr.Content = pSNR.ToString() + " dB"; } int filter1; StreamingCallbackFunc sh = StreamingCB; if (!SetFilter(17, sh, 4, 1, &filter1)) { log("Filter fail"); } else { log("Filter set"); } } } } [/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Satellite TV receivers & systems support forums
Satellite PC Card Receivers, Internet by Satellite
StreamReader.dll in C#?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top