|
Or you can just abandon the serial and parallel ports entirely (since todays PC's don't even have parallel ports anymore!) and use something like a Phidget Interface and motor controller. Go to Phidgets.com[^]. That way, you won't risk burning up the port that is on your motherboard.
|
|
|
|
|
Hey, that's pretty nifty. Thanks.
|
|
|
|
|
Cool Stuff.
All the best,
Dan
|
|
|
|
|
Also, it would be best if, in the startup of your app, you set the parallel port to a known state before you really get into your main code.
|
|
|
|
|
How do I install a game I've made in XNA(using Visual Studio 2008) on a computer that does not have Visual Studio? Please help. the simplest way would be the most Awesome
|
|
|
|
|
I don't know about XNA in particular.
In general, one does not need Visual Studio to execute a program developed with Visual Studio.
For managed code (such as C#), one needs the .NET FrameWork, which comes in several versions; one needs the version that was targeted, there is no automatic substitution if your system happens to have a higher version.
AFAIK you need to install .NET separately, you can't just ship it with your app and make it look as a single install. Microsoft does not give redistribution rights for .NET, you'd have to install from their site.
BTW: modern Windows versions (Vista, 7) normally come with a number of .NET versions pre-installed, typically all that were available when the Windows version became available itself. So if e.g. you build for .NET 2.0, it should just run fine on any Vista/7 system as is.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I would think you would need the XNA Framework[^].
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
for execution of a .net program u doesn't need to install visual studio you just need to install the .NET framework versions like .Net2.0 or .Net 3.0 or .NEt3.5
|
|
|
|
|
Like Silverlight and Windows Phone 7, XNA has its own .NET framework
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello,
I need to send string messages from Java program to C# program in real time.
There are many examples in the Internet but I can't find anything good for my purpose that is (probably) Java client (sockets code) and c# server (sockets code).
For example, I tred this: http://mediakey.dk/~cc/java-and-c-client-server-socket-programming/ but without success. (It seems connection can't be established when using that code).
I would be especially grateful if anyone could give me a simple working code for this task.
Thank you.
|
|
|
|
|
I'm not sure I understand. Socket communication isn't language specific; one side cannot tell what programming language the other side has been using. As a net result, you could look for an entirely C# example, and use half of it; and then look for an entirely Java example, and use the other half of it.
So maybe you should connect two PCs running a C# app; then the same two PCs running a Java app. And finally mix the apps up (or choose a non-PC target if that is what you want).
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Thanks. it is very simple. There are two programs running on one PC. One program written on Java and needs to pass string data to a program written on C#.
|
|
|
|
|
So? if its only one PC, then first get it to work between 2 C# apps on the same PC. Then try again with 2 Java apps on the same PC. Now take one each and that should work too.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
There could be a problem if he's trying to send the string with default serialization
|
|
|
|
|
Um...sockets is C technically
Yes, communication protocols are language independent, but not sockets. (of course I'm busting your chops Luc )
Regardless, the OP needs to focus on protocol, not languages...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: Um...sockets is C technically
Are you sure? I have used sockets between a Java client on Windows and a C server on UNIX with no problems.
The best things in life are not things.
|
|
|
|
|
It's been wrapped and/or implemented by frameworks like Win32 (WinSock), Java,.NET, etc., but Berkeley sockets was originally C. Just sayin...
Of course, "socket" these days pretty much is used generically to describe a communication endpoint.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Point taken.
The best things in life are not things.
|
|
|
|
|
So here's my c# code:
class Program
{
private StreamWriter swSender;
private StreamReader srReceiver;
private TcpClient tcpServer;
private Thread thrMessaging;
private IPAddress ipAddr;
private bool Connected;
private string receivedData;
static void Main(string[] args)
{
System.Diagnostics.Process.Start(Path.GetFullPath("RunJar.bat"));
Console.WriteLine("C# Sockets Program has started.");
try
{
Program prog = new Program();
prog.InitializeConnection();
}
catch (Exception e) { Console.WriteLine(e); }
Console.ReadLine();
}
private void InitializeConnection()
{
string ipAdress = "127.0.0.1";
ipAddr = IPAddress.Parse(ipAdress);
tcpServer = new TcpClient();
try
{
tcpServer.Connect(ipAddr, 1800);
swSender = new StreamWriter(tcpServer.GetStream());
thrMessaging = new Thread(new ThreadStart(ReceiveMessages));
thrMessaging.Start();
Connected = true;
}
catch (Exception e2)
{
Console.WriteLine(e2.ToString());
}
}
private void ReceiveMessages()
{
srReceiver = new StreamReader(tcpServer.GetStream());
while (Connected)
{
String con = srReceiver.ReadLine();
string StringMessage = HttpUtility.UrlDecode(con, System.Text.Encoding.UTF8);
processMessage(StringMessage);
}
}
private void processMessage(String p)
{
Console.WriteLine(p);
}
private void SendMessage(String p)
{
if (p != "")
{
p = HttpUtility.UrlEncode(p, System.Text.Encoding.UTF8);
swSender.WriteLine(p);
swSender.Flush();
}
}
}
And here's my Java code:
public class JavaSocket {
public void runJavaSocket() {
System.out.println("Java Sockets Program has started.");
try {
Socket s = new Socket("127.0.0.1", 1800);
s.connect(new InetSocketAddress("127.0.0.1", 1800), 10000);
while (!s.isConnected()) {
s.connect(new InetSocketAddress("127.0.0.1", 1800), 10000);
}
System.out.println("java Socket Connected.");
OutputStream out = s.getOutputStream();
out.write("helloFromjavaCode".getBytes());
out.flush();
out.close();
} catch (Exception e) {
System.out.println(e);
}
try {
@SuppressWarnings("unused")
int a = System.in.read();
}
catch (Exception e) {}
}
}
Here's the exception that c# program gives:
C# Sockets Program has started.
System.Net.Sockets.SocketException (0x80004005): No connection could be made bec
ause the target machine actively refused it 127.0.0.1:1800
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddre
ss socketAddress)
at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
at System.Net.Sockets.TcpClient.Connect(IPEndPoint remoteEP)
at System.Net.Sockets.TcpClient.Connect(IPAddress address, Int32 port)
at CsSocket.Program.InitializeConnection() in C:\Users\Sergii\documents\visua
l studio 2010\Projects\CsSocket\CsSocket\Program.cs:line 66
Here's the exception that Java program gives:
java.net.ConnectException: Connection refused: connect
What is wrong with my code?
|
|
|
|
|
Thank everyone for trying to help! I think I've found a good, working solution. Using UDP sockets:
Java code:
public void runJavaSocket() {
System.out.println("Java Sockets Program has started."); int i=0;
try {
DatagramSocket socket = new DatagramSocket();
System.out.println("Sending the udp socket...");
socket.send(toDatagram("HI",InetAddress.getByName("127.0.0.1"),3800));
while (true)
{
System.out.println("Sending hi " + i);
Thread.currentThread();
Thread.sleep(1000);
socket.send(toDatagram("HI " + String.valueOf(i),InetAddress.getByName("127.0.0.1"),3800));
i++;
}
} catch (Exception e) {
e.printStackTrace();
}
}
public DatagramPacket toDatagram(
String s, InetAddress destIA, int destPort) {
byte[] buf = new byte[s.length() + 1];
s.getBytes(0, s.length(), buf, 0);
return new DatagramPacket(buf, buf.length,
destIA, destPort);
}
C# code:
string returnData;
byte[] receiveBytes;
using (UdpClient udpClient = new UdpClient(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 3800)))
{
IPEndPoint remoteIpEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 3800);
while (true)
{
receiveBytes = udpClient.Receive(ref remoteIpEndPoint);
returnData = Encoding.ASCII.GetString(receiveBytes);
Console.WriteLine(returnData);
}
}
|
|
|
|
|
I need to read an XML file and output it as an HTML table. I have a background in Access, SQL and Crystal Reports so have experience with coding and relational databases. I'm now developing an application in Sharepoint using C# reading an XML file which I am unfamiliar with. The XML file has a structure as below:
<?xml version="1.0" encoding="ISO-8859-1"?>
<loan>
<library>
<libraryName>Auckland Library</libraryName>
<item>
<duedate>24-05-2011</duedate>
<title>Empire Burlesque</title>
</item>
<item>
<duedate>12-05-2011</duedate>
<title>Hide your Heart</title>
</item>
</library>
<library>
<libraryName>Waikato Library</libraryName>
<item>
[...]
</item>
</library>
</loan>
The data is to be displayed as an html table, sorted by Library, duedate and title (in that order). The XML data is not sorted. Overdue books are highlighted:
Auckland Library Items | Due
|
---|
Hide Your Heart | 12 May
| Empire Burlesque | 24 May
| Waikato Library Items | Due
|
---|
... | ...
|
I've only had limited success so far and its giving me a headache. Can anyone suggest the best way to do this? Thanks.
|
|
|
|
|
Steps.
1.Learn the basics of C#
2. Figure out what the Html needs to look like. That has nothing to do with XML.
3. Figure out how to parse (step through) the XML. That has nothing to do with Html.
4. Put 2 and 3 together.
Ask questions about each of the specific tasks.
|
|
|
|
|
|
In my experience it is more like....
5. Find good sales person.
6. Profit!
Regardless of steps before 5, you will not get to 6 without 5.
|
|
|
|
|